diff --git a/Libraries/Renderer/REVISION b/Libraries/Renderer/REVISION index d45d99aeb1adb8..9be2711e1c8310 100644 --- a/Libraries/Renderer/REVISION +++ b/Libraries/Renderer/REVISION @@ -1 +1 @@ -6cff70a740d1e6ad10070ebf88514bd3a49d0f0d +19f6fe170ce920d7183a5620f4e218334c8bac62 \ No newline at end of file diff --git a/Libraries/Renderer/implementations/ReactFabric-dev.fb.js b/Libraries/Renderer/implementations/ReactFabric-dev.fb.js index aafcdcead33c33..1b3fd6c211d332 100644 --- a/Libraries/Renderer/implementations/ReactFabric-dev.fb.js +++ b/Libraries/Renderer/implementations/ReactFabric-dev.fb.js @@ -15,13 +15,110 @@ if (__DEV__) { (function() { "use strict"; +var React = require("react"); require("react-native/Libraries/ReactPrivate/ReactNativePrivateInitializeCore"); var ReactNativePrivateInterface = require("react-native/Libraries/ReactPrivate/ReactNativePrivateInterface"); -var React = require("react"); -var Scheduler = require("scheduler"); var checkPropTypes = require("prop-types/checkPropTypes"); +var Scheduler = require("scheduler"); var tracing = require("scheduler/tracing"); +var ReactSharedInternals = + React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED; // Prevent newer renderers from RTE when used with older react package versions. +// Current owner and dispatcher used to share the same ref, +// but PR #14548 split them out to better support the react-debug-tools package. + +if (!ReactSharedInternals.hasOwnProperty("ReactCurrentDispatcher")) { + ReactSharedInternals.ReactCurrentDispatcher = { + current: null + }; +} + +if (!ReactSharedInternals.hasOwnProperty("ReactCurrentBatchConfig")) { + ReactSharedInternals.ReactCurrentBatchConfig = { + suspense: null + }; +} + +// by calls to these methods by a Babel plugin. +// +// In PROD (or in packages without access to React internals), +// they are left as they are instead. + +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]; + } + + 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]; + } + + printWarning("error", format, args); + } +} + +function printWarning(level, format, args) { + // When changing this logic, you might want to also + // update consoleWithStackDev.www.js as well. + { + var hasExistingStack = + args.length > 0 && + typeof args[args.length - 1] === "string" && + args[args.length - 1].indexOf("\n in") === 0; + + if (!hasExistingStack) { + var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame; + var stack = ReactDebugCurrentFrame.getStackAddendum(); + + if (stack !== "") { + format += "%s"; + args = args.concat([stack]); + } + } + + var argsWithFormat = args.map(function(item) { + return "" + item; + }); // Careful: RN currently depends on this prefix + + argsWithFormat.unshift("Warning: " + format); // We intentionally don't use spread (or .apply) directly because it + // breaks IE9: https://github.com/facebook/react/issues/13610 + // eslint-disable-next-line react-internal/no-production-logging + + Function.prototype.apply.call(console[level], console, argsWithFormat); + + try { + // --- Welcome to debugging React --- + // This error was thrown as a convenience so that you can use this stack + // to find the callsite that caused this warning to fire. + var argIndex = 0; + var message = + "Warning: " + + format.replace(/%s/g, function() { + return args[argIndex++]; + }); + throw new Error(message); + } catch (x) {} + } +} + /** * Use invariant() to assert state which your program assumes to be true. * @@ -559,71 +656,6 @@ function clearCaughtError() { } } -/** - * Similar to invariant but only logs a warning if the condition is not met. - * This can be used to log issues in development environments in critical - * paths. Removing the logging code for production environments will keep the - * same logic and follow the same code paths. - */ -var warningWithoutStack = function() {}; - -{ - warningWithoutStack = function(condition, format) { - for ( - var _len = arguments.length, - args = new Array(_len > 2 ? _len - 2 : 0), - _key = 2; - _key < _len; - _key++ - ) { - args[_key - 2] = arguments[_key]; - } - - if (format === undefined) { - throw new Error( - "`warningWithoutStack(condition, format, ...args)` requires a warning " + - "message argument" - ); - } - - if (args.length > 8) { - // Check before the condition to catch violations early. - throw new Error( - "warningWithoutStack() currently supports at most 8 arguments." - ); - } - - if (condition) { - return; - } - - if (typeof console !== "undefined") { - var argsWithFormat = args.map(function(item) { - return "" + item; - }); - argsWithFormat.unshift("Warning: " + format); // We intentionally don't use spread (or .apply) directly because it - // breaks IE9: https://github.com/facebook/react/issues/13610 - - Function.prototype.apply.call(console.error, console, argsWithFormat); - } - - try { - // --- Welcome to debugging React --- - // This error was thrown as a convenience so that you can use this stack - // to find the callsite that caused this warning to fire. - var argIndex = 0; - var message = - "Warning: " + - format.replace(/%s/g, function() { - return args[argIndex++]; - }); - throw new Error(message); - } catch (x) {} - }; -} - -var warningWithoutStack$1 = warningWithoutStack; - var getFiberCurrentPropsFromNode = null; var getInstanceFromNode = null; var getNodeFromInstance = null; @@ -637,13 +669,12 @@ function setComponentTree( getNodeFromInstance = getNodeFromInstanceImpl; { - !(getNodeFromInstance && getInstanceFromNode) - ? warningWithoutStack$1( - false, - "EventPluginUtils.setComponentTree(...): Injected " + - "module is missing getNodeFromInstance or getInstanceFromNode." - ) - : void 0; + if (!getNodeFromInstance || !getInstanceFromNode) { + error( + "EventPluginUtils.setComponentTree(...): Injected " + + "module is missing getNodeFromInstance or getInstanceFromNode." + ); + } } } var validateEventDispatches; @@ -664,9 +695,10 @@ var validateEventDispatches; : dispatchInstances ? 1 : 0; - !(instancesIsArr === listenersIsArr && instancesLen === listenersLen) - ? warningWithoutStack$1(false, "EventPluginUtils: Invalid `event`.") - : void 0; + + if (instancesIsArr !== listenersIsArr || instancesLen !== listenersLen) { + error("EventPluginUtils: Invalid `event`."); + } }; } /** @@ -1093,6 +1125,7 @@ var DehydratedFragment = 18; var SuspenseListComponent = 19; var FundamentalComponent = 20; var ScopeComponent = 21; +var Chunk = 22; function getParent(inst) { do { @@ -1230,9 +1263,9 @@ function listenerAtPhase(inst, event, propagationPhase) { function accumulateDirectionalDispatches(inst, phase, event) { { - !inst - ? warningWithoutStack$1(false, "Dispatching inst must not be null") - : void 0; + if (!inst) { + error("Dispatching inst must not be null"); + } } var listener = listenerAtPhase(inst, event, phase); @@ -1577,7 +1610,7 @@ function getPooledWarningPropertyDefinition(propName, getVal) { function set(val) { var action = isFunction ? "setting the method" : "setting the property"; - warn(action, "This is effectively a no-op"); + warn$$1(action, "This is effectively a no-op"); return val; } @@ -1586,24 +1619,22 @@ function getPooledWarningPropertyDefinition(propName, getVal) { var result = isFunction ? "This is a no-op function" : "This is set to null"; - warn(action, result); + warn$$1(action, result); return getVal; } - function warn(action, result) { - var warningCondition = false; - !warningCondition - ? warningWithoutStack$1( - false, - "This synthetic event is reused for performance reasons. If you're seeing this, " + - "you're %s `%s` on a released/nullified synthetic event. %s. " + - "If you must keep the original synthetic event around, use event.persist(). " + - "See https://fb.me/react-event-pooling for more information.", - action, - propName, - result - ) - : void 0; + function warn$$1(action, result) { + { + error( + "This synthetic event is reused for performance reasons. If you're seeing this, " + + "you're %s `%s` on a released/nullified synthetic event. %s. " + + "If you must keep the original synthetic event around, use event.persist(). " + + "See https://fb.me/react-event-pooling for more information.", + action, + propName, + result + ); + } } } @@ -1748,15 +1779,14 @@ function getTouchIdentifier(_ref) { } { - !(identifier <= MAX_TOUCH_BANK) - ? warningWithoutStack$1( - false, - "Touch identifier %s is greater than maximum supported %s which causes " + - "performance issues backfilling array locations for all of the indices.", - identifier, - MAX_TOUCH_BANK - ) - : void 0; + if (identifier > MAX_TOUCH_BANK) { + error( + "Touch identifier %s is greater than maximum supported %s which causes " + + "performance issues backfilling array locations for all of the indices.", + identifier, + MAX_TOUCH_BANK + ); + } } return identifier; @@ -1788,12 +1818,15 @@ function recordTouchMove(touch) { touchRecord.currentTimeStamp = timestampForTouch(touch); touchHistory.mostRecentTimeStamp = timestampForTouch(touch); } else { - console.warn( - "Cannot record touch move without a touch start.\n" + "Touch Move: %s\n", - "Touch Bank: %s", - printTouch(touch), - printTouchBank() - ); + { + warn( + "Cannot record touch move without a touch start.\n" + + "Touch Move: %s\n" + + "Touch Bank: %s", + printTouch(touch), + printTouchBank() + ); + } } } @@ -1810,12 +1843,15 @@ function recordTouchEnd(touch) { touchRecord.currentTimeStamp = timestampForTouch(touch); touchHistory.mostRecentTimeStamp = timestampForTouch(touch); } else { - console.warn( - "Cannot record touch end without a touch start.\n" + "Touch End: %s\n", - "Touch Bank: %s", - printTouch(touch), - printTouchBank() - ); + { + warn( + "Cannot record touch end without a touch start.\n" + + "Touch End: %s\n" + + "Touch Bank: %s", + printTouch(touch), + printTouchBank() + ); + } } } @@ -1866,9 +1902,10 @@ var ResponderTouchHistoryStore = { { var activeRecord = touchBank[touchHistory.indexOfSingleActiveTouch]; - !(activeRecord != null && activeRecord.touchActive) - ? warningWithoutStack$1(false, "Cannot find single active touch.") - : void 0; + + if (activeRecord == null || !activeRecord.touchActive) { + error("Cannot find single active touch."); + } } } } @@ -2397,9 +2434,12 @@ var ResponderEventPlugin = { if (trackedTouchCount >= 0) { trackedTouchCount -= 1; } else { - console.warn( - "Ended a touch event which was not counted in `trackedTouchCount`." - ); + { + warn( + "Ended a touch event which was not counted in `trackedTouchCount`." + ); + } + return null; } } @@ -2575,11 +2615,13 @@ var enableProfilerTimer = true; var enableSchedulerTracing = true; var enableSuspenseServerRenderer = false; +var enableChunksAPI = false; + var debugRenderPhaseSideEffectsForStrictMode = true; var replayFailedUnitOfWorkWithInvokeGuardedCallback = true; var warnAboutDeprecatedLifecycles = true; -var enableFlareAPI = false; +var enableDeprecatedFlareAPI = false; var enableFundamentalAPI = false; var enableScopeAPI = false; @@ -2590,6 +2632,7 @@ var warnAboutDefaultPropsOnFunctionComponents = false; var warnAboutStringRefs = false; var disableLegacyContext = false; var disableSchedulerTimeoutBasedOnReactExpirationTime = false; +var enableTrainModelFix = false; // Only used in www builds. // Flow magic to verify the exports of this file match the original version. @@ -2670,23 +2713,6 @@ function set(key, value) { key._reactInternalFiber = value; } -var ReactSharedInternals = - React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED; // Prevent newer renderers from RTE when used with older react package versions. -// Current owner and dispatcher used to share the same ref, -// but PR #14548 split them out to better support the react-debug-tools package. - -if (!ReactSharedInternals.hasOwnProperty("ReactCurrentDispatcher")) { - ReactSharedInternals.ReactCurrentDispatcher = { - current: null - }; -} - -if (!ReactSharedInternals.hasOwnProperty("ReactCurrentBatchConfig")) { - ReactSharedInternals.ReactCurrentBatchConfig = { - suspense: null - }; -} - // The Symbol used to tag the ReactElement-like types. If there is no native Symbol // nor polyfill, then a plain number is used for performance. var hasSymbol = typeof Symbol === "function" && Symbol.for; @@ -2713,6 +2739,7 @@ var REACT_SUSPENSE_LIST_TYPE = hasSymbol : 0xead8; var REACT_MEMO_TYPE = hasSymbol ? Symbol.for("react.memo") : 0xead3; var REACT_LAZY_TYPE = hasSymbol ? Symbol.for("react.lazy") : 0xead4; +var REACT_CHUNK_TYPE = hasSymbol ? Symbol.for("react.chunk") : 0xead9; var REACT_FUNDAMENTAL_TYPE = hasSymbol ? Symbol.for("react.fundamental") : 0xead5; @@ -2736,43 +2763,6 @@ function getIteratorFn(maybeIterable) { return null; } -/** - * Similar to invariant but only logs a warning if the condition is not met. - * This can be used to log issues in development environments in critical - * paths. Removing the logging code for production environments will keep the - * same logic and follow the same code paths. - */ - -var warning = warningWithoutStack$1; - -{ - warning = function(condition, format) { - if (condition) { - return; - } - - var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame; - var stack = ReactDebugCurrentFrame.getStackAddendum(); // eslint-disable-next-line react-internal/warning-and-invariant-args - - for ( - var _len = arguments.length, - args = new Array(_len > 2 ? _len - 2 : 0), - _key = 2; - _key < _len; - _key++ - ) { - args[_key - 2] = arguments[_key]; - } - - warningWithoutStack$1.apply( - void 0, - [false, format + "%s"].concat(args, [stack]) - ); - }; -} - -var warning$1 = warning; - var Uninitialized = -1; var Pending = 0; var Resolved = 1; @@ -2793,8 +2783,7 @@ function initializeLazyComponentType(lazyComponent) { { if (defaultExport === undefined) { - warning$1( - false, + error( "lazy: Expected the result of a dynamic import() call. " + "Instead received: %s\n\nYour code should look like: \n " + "const MyComponent = lazy(() => import('./MyComponent'))", @@ -2807,10 +2796,10 @@ function initializeLazyComponentType(lazyComponent) { lazyComponent._result = defaultExport; } }, - function(error) { + function(error$$1) { if (lazyComponent._status === Pending) { lazyComponent._status = Rejected; - lazyComponent._result = error; + lazyComponent._result = error$$1; } } ); @@ -2833,8 +2822,7 @@ function getComponentName(type) { { if (typeof type.tag === "number") { - warningWithoutStack$1( - false, + error( "Received an unexpected object in getComponentName(). " + "This is likely a bug in React. Please file an issue." ); @@ -2883,6 +2871,9 @@ function getComponentName(type) { case REACT_MEMO_TYPE: return getComponentName(type.type); + case REACT_CHUNK_TYPE: + return getComponentName(type.render); + case REACT_LAZY_TYPE: { var thenable = type; var resolvedThenable = refineResolvedLazyComponent(thenable); @@ -3006,17 +2997,18 @@ function isMounted(component) { if (owner !== null && owner.tag === ClassComponent) { var ownerFiber = owner; var instance = ownerFiber.stateNode; - !instance._warnedAboutRefsInRender - ? warningWithoutStack$1( - false, - "%s is accessing isMounted inside its render() function. " + - "render() should be a pure function of props and state. It should " + - "never access something that requires stale data from the previous " + - "render, such as refs. Move this logic to componentDidMount and " + - "componentDidUpdate instead.", - getComponentName(ownerFiber.type) || "A component" - ) - : void 0; + + if (!instance._warnedAboutRefsInRender) { + error( + "%s is accessing isMounted inside its render() function. " + + "render() should be a pure function of props and state. It should " + + "never access something that requires stale data from the previous " + + "render, such as refs. Move this logic to componentDidMount and " + + "componentDidUpdate instead.", + getComponentName(ownerFiber.type) || "A component" + ); + } + instance._warnedAboutRefsInRender = true; } } @@ -3284,17 +3276,19 @@ function throwOnStylesProp(component, props) { } } function warnForStyleProps(props, validAttributes) { - for (var key in validAttributes.style) { - if (!(validAttributes[key] || props[key] === undefined)) { - console.error( - "You are setting the style `{ " + - key + - ": ... }` as a prop. You " + - "should nest it in a style object. " + - "E.g. `{ style: { " + - key + - ": ... } }`" - ); + { + for (var key in validAttributes.style) { + if (!(validAttributes[key] || props[key] === undefined)) { + error( + "You are setting the style `{ %s" + + ": ... }` as a prop. You " + + "should nest it in a style object. " + + "E.g. `{ style: { %s" + + ": ... } }`", + key, + key + ); + } } } } @@ -3778,8 +3772,13 @@ function restoreStateOfTarget(target) { ); } - var props = getFiberCurrentPropsFromNode(internalInstance.stateNode); - restoreImpl(internalInstance.stateNode, internalInstance.type, props); + var stateNode = internalInstance.stateNode; // Guard against Fiber being unmounted. + + if (stateNode) { + var _props = getFiberCurrentPropsFromNode(stateNode); + + restoreImpl(internalInstance.stateNode, internalInstance.type, _props); + } } function needsStateRestore() { @@ -3813,16 +3812,9 @@ var batchedUpdatesImpl = function(fn, bookkeeping) { return fn(bookkeeping); }; -var discreteUpdatesImpl = function(fn, a, b, c) { - return fn(a, b, c); -}; - var flushDiscreteUpdatesImpl = function() {}; -var batchedEventUpdatesImpl = batchedUpdatesImpl; var isInsideEventHandler = false; -var isBatchingEventUpdates = false; - function finishEventHandler() { // Here we wait until all updates have propagated, which is important // when using controlled components within layers: @@ -3855,72 +3847,8 @@ function batchedUpdates(fn, bookkeeping) { finishEventHandler(); } } -function batchedEventUpdates(fn, a, b) { - if (isBatchingEventUpdates) { - // If we are currently inside another batch, we need to wait until it - // fully completes before restoring state. - return fn(a, b); - } - - isBatchingEventUpdates = true; - - try { - return batchedEventUpdatesImpl(fn, a, b); - } finally { - isBatchingEventUpdates = false; - finishEventHandler(); - } -} // This is for the React Flare event system - -function executeUserEventHandler(fn, value) { - var previouslyInEventHandler = isInsideEventHandler; - - try { - isInsideEventHandler = true; - var type = typeof value === "object" && value !== null ? value.type : ""; - invokeGuardedCallbackAndCatchFirstError(type, fn, undefined, value); - } finally { - isInsideEventHandler = previouslyInEventHandler; - } -} -function discreteUpdates(fn, a, b, c) { - var prevIsInsideEventHandler = isInsideEventHandler; - isInsideEventHandler = true; +// This is for the React Flare event system - try { - return discreteUpdatesImpl(fn, a, b, c); - } finally { - isInsideEventHandler = prevIsInsideEventHandler; - - if (!isInsideEventHandler) { - finishEventHandler(); - } - } -} -var lastFlushedEventTimeStamp = 0; -function flushDiscreteUpdatesIfNeeded(timeStamp) { - // event.timeStamp isn't overly reliable due to inconsistencies in - // how different browsers have historically provided the time stamp. - // Some browsers provide high-resolution time stamps for all events, - // some provide low-resolution time stamps for all events. FF < 52 - // even mixes both time stamps together. Some browsers even report - // negative time stamps or time stamps that are 0 (iOS9) in some cases. - // Given we are only comparing two time stamps with equality (!==), - // we are safe from the resolution differences. If the time stamp is 0 - // we bail-out of preventing the flush, which can affect semantics, - // such as if an earlier flush removes or adds event listeners that - // are fired in the subsequent flush. However, this is the same - // behaviour as we had before this change, so the risks are low. - if ( - !isInsideEventHandler && - (!enableFlareAPI || - timeStamp === 0 || - lastFlushedEventTimeStamp !== timeStamp) - ) { - lastFlushedEventTimeStamp = timeStamp; - flushDiscreteUpdatesImpl(); - } -} function setBatchingImplementation( _batchedUpdatesImpl, _discreteUpdatesImpl, @@ -3928,501 +3856,43 @@ function setBatchingImplementation( _batchedEventUpdatesImpl ) { batchedUpdatesImpl = _batchedUpdatesImpl; - discreteUpdatesImpl = _discreteUpdatesImpl; flushDiscreteUpdatesImpl = _flushDiscreteUpdatesImpl; - batchedEventUpdatesImpl = _batchedEventUpdatesImpl; -} - -function _inheritsLoose(subClass, superClass) { - subClass.prototype = Object.create(superClass.prototype); - subClass.prototype.constructor = subClass; - subClass.__proto__ = superClass; } -/** - * Class only exists for its Flow type. - */ -var ReactNativeComponent = - /*#__PURE__*/ - (function(_React$Component) { - _inheritsLoose(ReactNativeComponent, _React$Component); +function dispatchEvent(target, topLevelType, nativeEvent) { + var targetFiber = target; + var eventTarget = null; - function ReactNativeComponent() { - return _React$Component.apply(this, arguments) || this; + if (enableNativeTargetAsInstance) { + if (targetFiber != null) { + eventTarget = targetFiber.stateNode.canonical; } + } else { + eventTarget = nativeEvent.target; + } - var _proto = ReactNativeComponent.prototype; - - _proto.blur = function blur() {}; - - _proto.focus = function focus() {}; + batchedUpdates(function() { + // Heritage plugin event system + runExtractedPluginEventsInBatch( + topLevelType, + targetFiber, + nativeEvent, + eventTarget, + PLUGIN_EVENT_SYSTEM + ); + }); // React Native doesn't use ReactControlledComponent but if it did, here's + // where it would do it. +} - _proto.measure = function measure(callback) {}; +// can re-export everything from this module. - _proto.measureInWindow = function measureInWindow(callback) {}; - - _proto.measureLayout = function measureLayout( - relativeToNativeNode, - onSuccess, - onFail - ) {}; - - _proto.setNativeProps = function setNativeProps(nativeProps) {}; - - return ReactNativeComponent; - })(React.Component); // This type is only used for FlowTests. It shouldn't be imported directly - -var DiscreteEvent = 0; -var UserBlockingEvent = 1; -var ContinuousEvent = 2; - -// CommonJS interop named imports. - -var UserBlockingPriority = Scheduler.unstable_UserBlockingPriority; -var runWithPriority = Scheduler.unstable_runWithPriority; -var _nativeFabricUIManage$2 = nativeFabricUIManager; -var measureInWindow = _nativeFabricUIManage$2.measureInWindow; -var rootEventTypesToEventResponderInstances = new Map(); -var currentTimeStamp = 0; -var currentInstance = null; -var eventResponderContext = { - dispatchEvent: function(eventValue, eventListener, eventPriority) { - validateResponderContext(); - validateEventValue(eventValue); - - switch (eventPriority) { - case DiscreteEvent: { - flushDiscreteUpdatesIfNeeded(currentTimeStamp); - discreteUpdates(function() { - return executeUserEventHandler(eventListener, eventValue); - }); - break; - } - - case UserBlockingEvent: { - runWithPriority(UserBlockingPriority, function() { - return executeUserEventHandler(eventListener, eventValue); - }); - break; - } - - case ContinuousEvent: { - executeUserEventHandler(eventListener, eventValue); - break; - } - } - }, - isTargetWithinNode: function(childTarget, parentTarget) { - validateResponderContext(); - var childFiber = getFiberFromTarget(childTarget); - var parentFiber = getFiberFromTarget(parentTarget); - var node = childFiber; - - while (node !== null) { - if (node === parentFiber) { - return true; - } - - node = node.return; - } - - return false; - }, - getTargetBoundingRect: function(target, callback) { - measureInWindow(target.node, function(x, y, width, height) { - callback({ - left: x, - right: x + width, - top: y, - bottom: y + height - }); - }); - }, - addRootEventTypes: function(rootEventTypes) { - validateResponderContext(); - - for (var i = 0; i < rootEventTypes.length; i++) { - var rootEventType = rootEventTypes[i]; - var eventResponderInstance = currentInstance; - registerRootEventType(rootEventType, eventResponderInstance); - } - }, - removeRootEventTypes: function(rootEventTypes) { - validateResponderContext(); - - for (var i = 0; i < rootEventTypes.length; i++) { - var rootEventType = rootEventTypes[i]; - var rootEventResponders = rootEventTypesToEventResponderInstances.get( - rootEventType - ); - var rootEventTypesSet = currentInstance.rootEventTypes; - - if (rootEventTypesSet !== null) { - rootEventTypesSet.delete(rootEventType); - } - - if (rootEventResponders !== undefined) { - rootEventResponders.delete(currentInstance); - } - } - }, - getTimeStamp: function() { - validateResponderContext(); - return currentTimeStamp; - }, - getResponderNode: function() { - validateResponderContext(); - var responderFiber = currentInstance.fiber; - - if (responderFiber.tag === ScopeComponent) { - return null; - } - - return responderFiber.stateNode; - } -}; - -function validateEventValue(eventValue) { - if (typeof eventValue === "object" && eventValue !== null) { - var target = eventValue.target, - type = eventValue.type, - timeStamp = eventValue.timeStamp; - - if (target == null || type == null || timeStamp == null) { - throw new Error( - 'context.dispatchEvent: "target", "timeStamp", and "type" fields on event object are required.' - ); - } - - var showWarning = function(name) { - { - warning$1( - false, - "%s is not available on event objects created from event responder modules (React Flare). " + - 'Try wrapping in a conditional, i.e. `if (event.type !== "press") { event.%s }`', - name, - name - ); - } - }; - - eventValue.preventDefault = function() { - { - showWarning("preventDefault()"); - } - }; - - eventValue.stopPropagation = function() { - { - showWarning("stopPropagation()"); - } - }; - - eventValue.isDefaultPrevented = function() { - { - showWarning("isDefaultPrevented()"); - } - }; - - eventValue.isPropagationStopped = function() { - { - showWarning("isPropagationStopped()"); - } - }; // $FlowFixMe: we don't need value, Flow thinks we do - - Object.defineProperty(eventValue, "nativeEvent", { - get: function() { - { - showWarning("nativeEvent"); - } - } - }); - } -} - -function getFiberFromTarget(target) { - if (target === null) { - return null; - } - - return target.canonical._internalInstanceHandle || null; -} - -function createFabricResponderEvent(topLevelType, nativeEvent, target) { - return { - nativeEvent: nativeEvent, - target: target, - type: topLevelType - }; -} - -function validateResponderContext() { - if (!currentInstance) { - throw Error( - "An event responder context was used outside of an event cycle." - ); - } -} // TODO this function is almost an exact copy of the DOM version, we should -// somehow share the logic - -function responderEventTypesContainType(eventTypes, type) { - for (var i = 0, len = eventTypes.length; i < len; i++) { - if (eventTypes[i] === type) { - return true; - } - } - - return false; -} - -function validateResponderTargetEventTypes(eventType, responder) { - var targetEventTypes = responder.targetEventTypes; // Validate the target event type exists on the responder - - if (targetEventTypes !== null) { - return responderEventTypesContainType(targetEventTypes, eventType); - } - - return false; -} // TODO this function is almost an exact copy of the DOM version, we should -// somehow share the logic - -function traverseAndHandleEventResponderInstances( - eventType, - targetFiber, - nativeEvent -) { - // Trigger event responders in this order: - // - Bubble target responder phase - // - Root responder phase - var responderEvent = createFabricResponderEvent( - eventType, - nativeEvent, - targetFiber !== null ? targetFiber.stateNode : null - ); - var visitedResponders = new Set(); - var node = targetFiber; - - while (node !== null) { - var _node = node, - dependencies = _node.dependencies, - tag = _node.tag; - - if ( - (tag === HostComponent || tag === ScopeComponent) && - dependencies !== null - ) { - var respondersMap = dependencies.responders; - - if (respondersMap !== null) { - var responderInstances = Array.from(respondersMap.values()); - - for (var i = 0, length = responderInstances.length; i < length; i++) { - var responderInstance = responderInstances[i]; - var props = responderInstance.props, - responder = responderInstance.responder, - state = responderInstance.state; - - if ( - !visitedResponders.has(responder) && - validateResponderTargetEventTypes(eventType, responder) - ) { - var onEvent = responder.onEvent; - visitedResponders.add(responder); - - if (onEvent !== null) { - currentInstance = responderInstance; - onEvent(responderEvent, eventResponderContext, props, state); - } - } - } - } - } - - node = node.return; - } // Root phase - - var rootEventResponderInstances = rootEventTypesToEventResponderInstances.get( - eventType - ); - - if (rootEventResponderInstances !== undefined) { - var _responderInstances = Array.from(rootEventResponderInstances); - - for (var _i = 0; _i < _responderInstances.length; _i++) { - var _responderInstance = _responderInstances[_i]; - var props = _responderInstance.props, - responder = _responderInstance.responder, - state = _responderInstance.state; - var onRootEvent = responder.onRootEvent; - - if (onRootEvent !== null) { - currentInstance = _responderInstance; - onRootEvent(responderEvent, eventResponderContext, props, state); - } - } - } -} // TODO this function is almost an exact copy of the DOM version, we should -// somehow share the logic - -function dispatchEventForResponderEventSystem( - topLevelType, - targetFiber, - nativeEvent -) { - var previousInstance = currentInstance; - var previousTimeStamp = currentTimeStamp; // We might want to control timeStamp another way here - - currentTimeStamp = Date.now(); - - try { - batchedEventUpdates(function() { - traverseAndHandleEventResponderInstances( - topLevelType, - targetFiber, - nativeEvent - ); - }); - } finally { - currentInstance = previousInstance; - currentTimeStamp = previousTimeStamp; - } -} // TODO this function is almost an exact copy of the DOM version, we should -// somehow share the logic - -function mountEventResponder(responder, responderInstance, props, state) { - var onMount = responder.onMount; - - if (onMount !== null) { - currentInstance = responderInstance; - - try { - batchedEventUpdates(function() { - onMount(eventResponderContext, props, state); - }); - } finally { - currentInstance = null; - } - } -} // TODO this function is almost an exact copy of the DOM version, we should -// somehow share the logic - -function unmountEventResponder(responderInstance) { - var responder = responderInstance.responder; - var onUnmount = responder.onUnmount; - - if (onUnmount !== null) { - var props = responderInstance.props, - state = responderInstance.state; - currentInstance = responderInstance; - - try { - batchedEventUpdates(function() { - onUnmount(eventResponderContext, props, state); - }); - } finally { - currentInstance = null; - } - } - - var rootEventTypesSet = responderInstance.rootEventTypes; - - if (rootEventTypesSet !== null) { - var rootEventTypes = Array.from(rootEventTypesSet); - - for (var i = 0; i < rootEventTypes.length; i++) { - var topLevelEventType = rootEventTypes[i]; - var rootEventResponderInstances = rootEventTypesToEventResponderInstances.get( - topLevelEventType - ); - - if (rootEventResponderInstances !== undefined) { - rootEventResponderInstances.delete(responderInstance); - } - } - } -} - -function registerRootEventType(rootEventType, responderInstance) { - var rootEventResponderInstances = rootEventTypesToEventResponderInstances.get( - rootEventType - ); - - if (rootEventResponderInstances === undefined) { - rootEventResponderInstances = new Set(); - rootEventTypesToEventResponderInstances.set( - rootEventType, - rootEventResponderInstances - ); - } - - var rootEventTypesSet = responderInstance.rootEventTypes; - - if (rootEventTypesSet === null) { - rootEventTypesSet = responderInstance.rootEventTypes = new Set(); - } - - if (!!rootEventTypesSet.has(rootEventType)) { - throw Error( - 'addRootEventTypes() found a duplicate root event type of "' + - rootEventType + - '". This might be because the event type exists in the event responder "rootEventTypes" array or because of a previous addRootEventTypes() using this root event type.' - ); - } - - rootEventTypesSet.add(rootEventType); - rootEventResponderInstances.add(responderInstance); -} - -function addRootEventTypesForResponderInstance( - responderInstance, - rootEventTypes -) { - for (var i = 0; i < rootEventTypes.length; i++) { - var rootEventType = rootEventTypes[i]; - registerRootEventType(rootEventType, responderInstance); - } -} - -function dispatchEvent(target, topLevelType, nativeEvent) { - var targetFiber = target; - - if (enableFlareAPI) { - // React Flare event system - dispatchEventForResponderEventSystem(topLevelType, target, nativeEvent); - } - - var eventTarget = null; - - if (enableNativeTargetAsInstance) { - if (targetFiber != null) { - eventTarget = targetFiber.stateNode.canonical; - } - } else { - eventTarget = nativeEvent.target; - } - - batchedUpdates(function() { - // Heritage plugin event system - runExtractedPluginEventsInBatch( - topLevelType, - targetFiber, - nativeEvent, - eventTarget, - PLUGIN_EVENT_SYSTEM - ); - }); // React Native doesn't use ReactControlledComponent but if it did, here's - // where it would do it. -} - -// 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." - ); - } -} // Mutation (when unsupported) +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." + ); + } +} // Mutation (when unsupported) var supportsMutation = false; var appendChild = shim; @@ -4478,21 +3948,21 @@ var didNotFindHydratableInstance = shim$1; var didNotFindHydratableTextInstance = shim$1; var didNotFindHydratableSuspenseInstance = shim$1; -var _nativeFabricUIManage$1 = nativeFabricUIManager; -var createNode = _nativeFabricUIManage$1.createNode; -var cloneNode = _nativeFabricUIManage$1.cloneNode; -var cloneNodeWithNewChildren = _nativeFabricUIManage$1.cloneNodeWithNewChildren; +var _nativeFabricUIManage = nativeFabricUIManager; +var createNode = _nativeFabricUIManage.createNode; +var cloneNode = _nativeFabricUIManage.cloneNode; +var cloneNodeWithNewChildren = _nativeFabricUIManage.cloneNodeWithNewChildren; var cloneNodeWithNewChildrenAndProps = - _nativeFabricUIManage$1.cloneNodeWithNewChildrenAndProps; -var cloneNodeWithNewProps = _nativeFabricUIManage$1.cloneNodeWithNewProps; -var createChildNodeSet = _nativeFabricUIManage$1.createChildSet; -var appendChildNode = _nativeFabricUIManage$1.appendChild; -var appendChildNodeToSet = _nativeFabricUIManage$1.appendChildToSet; -var completeRoot = _nativeFabricUIManage$1.completeRoot; -var registerEventHandler = _nativeFabricUIManage$1.registerEventHandler; -var fabricMeasure = _nativeFabricUIManage$1.measure; -var fabricMeasureInWindow = _nativeFabricUIManage$1.measureInWindow; -var fabricMeasureLayout = _nativeFabricUIManage$1.measureLayout; + _nativeFabricUIManage.cloneNodeWithNewChildrenAndProps; +var cloneNodeWithNewProps = _nativeFabricUIManage.cloneNodeWithNewProps; +var createChildNodeSet = _nativeFabricUIManage.createChildSet; +var appendChildNode = _nativeFabricUIManage.appendChild; +var appendChildNodeToSet = _nativeFabricUIManage.appendChildToSet; +var completeRoot = _nativeFabricUIManage.completeRoot; +var registerEventHandler = _nativeFabricUIManage.registerEventHandler; +var fabricMeasure = _nativeFabricUIManage.measure; +var fabricMeasureInWindow = _nativeFabricUIManage.measureInWindow; +var fabricMeasureLayout = _nativeFabricUIManage.measureLayout; var getViewConfigForType = ReactNativePrivateInterface.ReactNativeViewConfigRegistry.get; // Counter for uniquely identifying views. // % 10 === 1 means it is a rootTag. @@ -4563,10 +4033,12 @@ var ReactFabricHostComponent = typeof relativeToNativeNode === "number" || !(relativeToNativeNode instanceof ReactFabricHostComponent) ) { - warningWithoutStack$1( - false, - "Warning: ref.measureLayout must be called with a ref to a native component." - ); + { + error( + "Warning: ref.measureLayout must be called with a ref to a native component." + ); + } + return; } @@ -4579,10 +4051,10 @@ var ReactFabricHostComponent = }; _proto.setNativeProps = function setNativeProps(nativeProps) { - warningWithoutStack$1( - false, - "Warning: setNativeProps is not currently supported in Fabric" - ); + { + error("Warning: setNativeProps is not currently supported in Fabric"); + } + return; }; @@ -4797,28 +4269,17 @@ function finalizeContainerChildren(container, newChildren) { completeRoot(container, newChildren); } -function mountResponderInstance( +function DEPRECATED_mountResponderInstance( responder, responderInstance, props, state, instance ) { - if (enableFlareAPI) { - var rootEventTypes = responder.rootEventTypes; - - if (rootEventTypes !== null) { - addRootEventTypesForResponderInstance(responderInstance, rootEventTypes); - } - - mountEventResponder(responder, responderInstance, props, state); - } + throw new Error("Not yet implemented."); } -function unmountResponderInstance(responderInstance) { - if (enableFlareAPI) { - // TODO stop listening to targetEventTypes - unmountEventResponder(responderInstance); - } +function DEPRECATED_unmountResponderInstance(responderInstance) { + throw new Error("Not yet implemented."); } function getFundamentalComponentInstance(fundamentalInstance) { throw new Error("Not yet implemented."); @@ -4841,6 +4302,9 @@ function cloneFundamentalInstance(fundamentalInstance) { function getInstanceFromNode$1(node) { throw new Error("Not yet implemented."); } +function beforeRemoveInstance(instance) { + // noop +} var BEFORE_SLASH_RE = /^(.*)[\\\/]/; var describeComponentFrame = function(name, source, ownerName) { @@ -5424,7 +4888,7 @@ function createCursor(defaultValue) { function pop(cursor, fiber) { if (index < 0) { { - warningWithoutStack$1(false, "Unexpected pop."); + error("Unexpected pop."); } return; @@ -5432,7 +4896,7 @@ function pop(cursor, fiber) { { if (fiber !== fiberStack[index]) { - warningWithoutStack$1(false, "Unexpected Fiber popped."); + error("Unexpected Fiber popped."); } } @@ -5619,8 +5083,8 @@ function processChildContext(fiber, type, parentContext) { if (!warnedAboutMissingGetChildContext[componentName]) { warnedAboutMissingGetChildContext[componentName] = true; - warningWithoutStack$1( - false, + + error( "%s.childContextTypes is specified but there is no getChildContext() method " + "on the instance. You can either define getChildContext() on %s or remove " + "childContextTypes from it.", @@ -5819,7 +5283,7 @@ var fakeCallbackNode = {}; // Except for NoPriority, these correspond to Schedul // avoid clashing with Scheduler's priorities. var ImmediatePriority = 99; -var UserBlockingPriority$1 = 98; +var UserBlockingPriority = 98; var NormalPriority = 97; var LowPriority = 96; var IdlePriority = 95; // NoPriority is the absence of priority. Also React-only. @@ -5851,7 +5315,7 @@ function getCurrentPriorityLevel() { return ImmediatePriority; case Scheduler_UserBlockingPriority: - return UserBlockingPriority$1; + return UserBlockingPriority; case Scheduler_NormalPriority: return NormalPriority; @@ -5873,7 +5337,7 @@ function reactPriorityToSchedulerPriority(reactPriorityLevel) { case ImmediatePriority: return Scheduler_ImmediatePriority; - case UserBlockingPriority$1: + case UserBlockingPriority: return Scheduler_UserBlockingPriority; case NormalPriority: @@ -5891,7 +5355,7 @@ function reactPriorityToSchedulerPriority(reactPriorityLevel) { } } -function runWithPriority$1(reactPriorityLevel, fn) { +function runWithPriority(reactPriorityLevel, fn) { var priorityLevel = reactPriorityToSchedulerPriority(reactPriorityLevel); return Scheduler_runWithPriority(priorityLevel, fn); } @@ -5941,7 +5405,7 @@ function flushSyncCallbackQueueImpl() { try { var _isSync = true; var queue = syncQueue; - runWithPriority$1(ImmediatePriority, function() { + runWithPriority(ImmediatePriority, function() { for (; i < queue.length; i++) { var callback = queue[i]; @@ -6076,7 +5540,7 @@ function inferPriorityFromExpirationTime(currentTime, expirationTime) { } if (msUntil <= HIGH_PRIORITY_EXPIRATION + HIGH_PRIORITY_BATCH_SIZE) { - return UserBlockingPriority$1; + return UserBlockingPriority; } if (msUntil <= LOW_PRIORITY_EXPIRATION + LOW_PRIORITY_BATCH_SIZE) { @@ -6139,78 +5603,6 @@ function shallowEqual(objA, objB) { return true; } -/** - * Forked from fbjs/warning: - * https://github.com/facebook/fbjs/blob/e66ba20ad5be433eb54423f2b097d829324d9de6/packages/fbjs/src/__forks__/warning.js - * - * Only change is we use console.warn instead of console.error, - * and do nothing when 'console' is not supported. - * This really simplifies the code. - * --- - * Similar to invariant but only logs a warning if the condition is not met. - * This can be used to log issues in development environments in critical - * paths. Removing the logging code for production environments will keep the - * same logic and follow the same code paths. - */ -var lowPriorityWarningWithoutStack = function() {}; - -{ - var printWarning = function(format) { - for ( - var _len = arguments.length, - args = new Array(_len > 1 ? _len - 1 : 0), - _key = 1; - _key < _len; - _key++ - ) { - args[_key - 1] = arguments[_key]; - } - - var argIndex = 0; - var message = - "Warning: " + - format.replace(/%s/g, function() { - return args[argIndex++]; - }); - - if (typeof console !== "undefined") { - console.warn(message); - } - - try { - // --- Welcome to debugging React --- - // This error was thrown as a convenience so that you can use this stack - // to find the callsite that caused this warning to fire. - throw new Error(message); - } catch (x) {} - }; - - lowPriorityWarningWithoutStack = function(condition, format) { - if (format === undefined) { - throw new Error( - "`lowPriorityWarningWithoutStack(condition, format, ...args)` requires a warning " + - "message argument" - ); - } - - if (!condition) { - for ( - var _len2 = arguments.length, - args = new Array(_len2 > 2 ? _len2 - 2 : 0), - _key2 = 2; - _key2 < _len2; - _key2++ - ) { - args[_key2 - 2] = arguments[_key2]; - } - - printWarning.apply(void 0, [format].concat(args)); - } - }; -} - -var lowPriorityWarningWithoutStack$1 = lowPriorityWarningWithoutStack; - var ReactStrictModeWarnings = { recordUnsafeLifecycleWarnings: function(fiber, instance) {}, flushPendingUnsafeLifecycleWarnings: function() {}, @@ -6381,8 +5773,8 @@ var ReactStrictModeWarnings = { if (UNSAFE_componentWillMountUniqueNames.size > 0) { var sortedNames = setToSortedString(UNSAFE_componentWillMountUniqueNames); - warningWithoutStack$1( - false, + + error( "Using UNSAFE_componentWillMount in strict mode is not recommended and may indicate bugs in your code. " + "See https://fb.me/react-unsafe-component-lifecycles for details.\n\n" + "* Move code with side effects to componentDidMount, and set initial state in the constructor.\n" + @@ -6396,8 +5788,7 @@ var ReactStrictModeWarnings = { UNSAFE_componentWillReceivePropsUniqueNames ); - warningWithoutStack$1( - false, + error( "Using UNSAFE_componentWillReceiveProps in strict mode is not recommended " + "and may indicate bugs in your code. " + "See https://fb.me/react-unsafe-component-lifecycles for details.\n\n" + @@ -6415,8 +5806,7 @@ var ReactStrictModeWarnings = { UNSAFE_componentWillUpdateUniqueNames ); - warningWithoutStack$1( - false, + error( "Using UNSAFE_componentWillUpdate in strict mode is not recommended " + "and may indicate bugs in your code. " + "See https://fb.me/react-unsafe-component-lifecycles for details.\n\n" + @@ -6429,8 +5819,7 @@ var ReactStrictModeWarnings = { if (componentWillMountUniqueNames.size > 0) { var _sortedNames3 = setToSortedString(componentWillMountUniqueNames); - lowPriorityWarningWithoutStack$1( - false, + warn( "componentWillMount has been renamed, and is not recommended for use. " + "See https://fb.me/react-unsafe-component-lifecycles for details.\n\n" + "* Move code with side effects to componentDidMount, and set initial state in the constructor.\n" + @@ -6448,8 +5837,7 @@ var ReactStrictModeWarnings = { componentWillReceivePropsUniqueNames ); - lowPriorityWarningWithoutStack$1( - false, + warn( "componentWillReceiveProps has been renamed, and is not recommended for use. " + "See https://fb.me/react-unsafe-component-lifecycles for details.\n\n" + "* Move data fetching code or side effects to componentDidUpdate.\n" + @@ -6468,8 +5856,7 @@ var ReactStrictModeWarnings = { if (componentWillUpdateUniqueNames.size > 0) { var _sortedNames5 = setToSortedString(componentWillUpdateUniqueNames); - lowPriorityWarningWithoutStack$1( - false, + warn( "componentWillUpdate has been renamed, and is not recommended for use. " + "See https://fb.me/react-unsafe-component-lifecycles for details.\n\n" + "* Move data fetching code or side effects to componentDidUpdate.\n" + @@ -6494,11 +5881,11 @@ var ReactStrictModeWarnings = { var strictRoot = findStrictRoot(fiber); if (strictRoot === null) { - warningWithoutStack$1( - false, + error( "Expected to find a StrictMode component in a strict mode tree. " + "This error is likely caused by a bug in React. Please file an issue." ); + return; } // Dedup strategy: Warn once per component. @@ -6531,8 +5918,8 @@ var ReactStrictModeWarnings = { }); var sortedNames = setToSortedString(uniqueNames); var strictRootComponentStack = getStackByFiberInDevAndProd(strictRoot); - warningWithoutStack$1( - false, + + error( "Legacy context API has been detected within a strict-mode tree." + "\n\nThe old API will be supported in all 16.x releases, but applications " + "using it should migrate to the new version." + @@ -7065,17 +6452,17 @@ function pushProvider(providerFiber, nextValue) { context._currentValue = nextValue; { - !( - context._currentRenderer === undefined || - context._currentRenderer === null || - context._currentRenderer === rendererSigil - ) - ? warningWithoutStack$1( - false, - "Detected multiple renderers concurrently rendering the " + - "same context provider. This is currently unsupported." - ) - : void 0; + if ( + context._currentRenderer !== undefined && + context._currentRenderer !== null && + context._currentRenderer !== rendererSigil + ) { + error( + "Detected multiple renderers concurrently rendering the " + + "same context provider. This is currently unsupported." + ); + } + context._currentRenderer = rendererSigil; } } else { @@ -7083,17 +6470,17 @@ function pushProvider(providerFiber, nextValue) { context._currentValue2 = nextValue; { - !( - context._currentRenderer2 === undefined || - context._currentRenderer2 === null || - context._currentRenderer2 === rendererSigil - ) - ? warningWithoutStack$1( - false, - "Detected multiple renderers concurrently rendering the " + - "same context provider. This is currently unsupported." - ) - : void 0; + if ( + context._currentRenderer2 !== undefined && + context._currentRenderer2 !== null && + context._currentRenderer2 !== rendererSigil + ) { + error( + "Detected multiple renderers concurrently rendering the " + + "same context provider. This is currently unsupported." + ); + } + context._currentRenderer2 = rendererSigil; } } @@ -7120,14 +6507,13 @@ function calculateChangedBits(context, newValue, oldValue) { : MAX_SIGNED_31_BIT_INT; { - !((changedBits & MAX_SIGNED_31_BIT_INT) === changedBits) - ? warning$1( - false, - "calculateChangedBits: Expected the return value to be a " + - "31-bit integer. Instead received: %s", - changedBits - ) - : void 0; + if ((changedBits & MAX_SIGNED_31_BIT_INT) !== changedBits) { + error( + "calculateChangedBits: Expected the return value to be a " + + "31-bit integer. Instead received: %s", + changedBits + ); + } } return changedBits | 0; @@ -7323,15 +6709,14 @@ function readContext(context, observedBits) { { // This warning would fire if you read context inside a Hook like useMemo. // Unlike the class check below, it's not enforced in production for perf. - !!isDisallowedContextReadInDEV - ? warning$1( - false, - "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()." - ) - : void 0; + if (isDisallowedContextReadInDEV) { + 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 (lastContextWithAllBitsObserved === context) { @@ -7472,38 +6857,32 @@ var currentlyProcessingQueue; currentlyProcessingQueue = null; } -function createUpdateQueue(baseState) { - var queue = { - baseState: baseState, - firstUpdate: null, - lastUpdate: null, - firstCapturedUpdate: null, - lastCapturedUpdate: null, - firstEffect: null, - lastEffect: null, - firstCapturedEffect: null, - lastCapturedEffect: null - }; - return queue; -} - -function cloneUpdateQueue(currentQueue) { +function initializeUpdateQueue(fiber) { var queue = { - baseState: currentQueue.baseState, - firstUpdate: currentQueue.firstUpdate, - lastUpdate: currentQueue.lastUpdate, - // TODO: With resuming, if we bail out and resuse the child tree, we should - // keep these effects. - firstCapturedUpdate: null, - lastCapturedUpdate: null, - firstEffect: null, - lastEffect: null, - firstCapturedEffect: null, - lastCapturedEffect: null + baseState: fiber.memoizedState, + baseQueue: null, + shared: { + pending: null + }, + effects: null }; - return queue; + fiber.updateQueue = queue; +} +function cloneUpdateQueue(current, workInProgress) { + // Clone the update queue from current. Unless it's already a clone. + var queue = workInProgress.updateQueue; + var currentQueue = current.updateQueue; + + if (queue === currentQueue) { + var clone = { + baseState: currentQueue.baseState, + baseQueue: currentQueue.baseQueue, + shared: currentQueue.shared, + effects: currentQueue.effects + }; + workInProgress.updateQueue = clone; + } } - function createUpdate(expirationTime, suspenseConfig) { var update = { expirationTime: expirationTime, @@ -7511,9 +6890,9 @@ function createUpdate(expirationTime, suspenseConfig) { tag: UpdateState, payload: null, callback: null, - next: null, - nextEffect: null + next: null }; + update.next = update; { update.priority = getCurrentPriorityLevel(); @@ -7521,136 +6900,62 @@ function createUpdate(expirationTime, suspenseConfig) { return update; } +function enqueueUpdate(fiber, update) { + var updateQueue = fiber.updateQueue; -function appendUpdateToQueue(queue, update) { - // Append the update to the end of the list. - if (queue.lastUpdate === null) { - // Queue is empty - queue.firstUpdate = queue.lastUpdate = update; - } else { - queue.lastUpdate.next = update; - queue.lastUpdate = update; + if (updateQueue === null) { + // Only occurs if the fiber has been unmounted. + return; } -} -function enqueueUpdate(fiber, update) { - // Update queues are created lazily. - var alternate = fiber.alternate; - var queue1; - var queue2; + var sharedQueue = updateQueue.shared; + var pending = sharedQueue.pending; - if (alternate === null) { - // There's only one fiber. - queue1 = fiber.updateQueue; - queue2 = null; - - if (queue1 === null) { - queue1 = fiber.updateQueue = createUpdateQueue(fiber.memoizedState); - } + if (pending === null) { + // This is the first update. Create a circular list. + update.next = update; } else { - // There are two owners. - queue1 = fiber.updateQueue; - queue2 = alternate.updateQueue; - - if (queue1 === null) { - if (queue2 === null) { - // Neither fiber has an update queue. Create new ones. - queue1 = fiber.updateQueue = createUpdateQueue(fiber.memoizedState); - queue2 = alternate.updateQueue = createUpdateQueue( - alternate.memoizedState - ); - } else { - // Only one fiber has an update queue. Clone to create a new one. - queue1 = fiber.updateQueue = cloneUpdateQueue(queue2); - } - } else { - if (queue2 === null) { - // Only one fiber has an update queue. Clone to create a new one. - queue2 = alternate.updateQueue = cloneUpdateQueue(queue1); - } else { - // Both owners have an update queue. - } - } + update.next = pending.next; + pending.next = update; } - if (queue2 === null || queue1 === queue2) { - // There's only a single queue. - appendUpdateToQueue(queue1, update); - } else { - // There are two queues. We need to append the update to both queues, - // while accounting for the persistent structure of the list — we don't - // want the same update to be added multiple times. - if (queue1.lastUpdate === null || queue2.lastUpdate === null) { - // One of the queues is not empty. We must add the update to both queues. - appendUpdateToQueue(queue1, update); - appendUpdateToQueue(queue2, update); - } else { - // Both queues are non-empty. The last update is the same in both lists, - // because of structural sharing. So, only append to one of the lists. - appendUpdateToQueue(queue1, update); // But we still need to update the `lastUpdate` pointer of queue2. - - queue2.lastUpdate = update; - } - } + sharedQueue.pending = update; { if ( - fiber.tag === ClassComponent && - (currentlyProcessingQueue === queue1 || - (queue2 !== null && currentlyProcessingQueue === queue2)) && + currentlyProcessingQueue === sharedQueue && !didWarnUpdateInsideUpdate ) { - warningWithoutStack$1( - false, + error( "An update (setState, replaceState, or forceUpdate) was scheduled " + "from inside an update function. Update functions should be pure, " + "with zero side-effects. Consider using componentDidUpdate or a " + "callback." ); + didWarnUpdateInsideUpdate = true; } } } function enqueueCapturedUpdate(workInProgress, update) { - // Captured updates go into a separate list, and only on the work-in- - // progress queue. - var workInProgressQueue = workInProgress.updateQueue; + var current = workInProgress.alternate; - if (workInProgressQueue === null) { - workInProgressQueue = workInProgress.updateQueue = createUpdateQueue( - workInProgress.memoizedState - ); - } else { - // TODO: I put this here rather than createWorkInProgress so that we don't - // clone the queue unnecessarily. There's probably a better way to - // structure this. - workInProgressQueue = ensureWorkInProgressQueueIsAClone( - workInProgress, - workInProgressQueue - ); - } // Append the update to the end of the list. + if (current !== null) { + // Ensure the work-in-progress queue is a clone + cloneUpdateQueue(current, workInProgress); + } // Captured updates go only on the work-in-progress queue. - if (workInProgressQueue.lastCapturedUpdate === null) { - // This is the first render phase update - workInProgressQueue.firstCapturedUpdate = workInProgressQueue.lastCapturedUpdate = update; - } else { - workInProgressQueue.lastCapturedUpdate.next = update; - workInProgressQueue.lastCapturedUpdate = update; - } -} + var queue = workInProgress.updateQueue; // Append the update to the end of the list. -function ensureWorkInProgressQueueIsAClone(workInProgress, queue) { - var current = workInProgress.alternate; + var last = queue.baseQueue; - if (current !== null) { - // If the work-in-progress queue is equal to the current queue, - // we need to clone it first. - if (queue === current.updateQueue) { - queue = workInProgress.updateQueue = cloneUpdateQueue(queue); - } + if (last === null) { + queue.baseQueue = update.next = update; + update.next = update; + } else { + update.next = last.next; + last.next = update; } - - return queue; } function getStateFromUpdate( @@ -7742,163 +7047,171 @@ function getStateFromUpdate( function processUpdateQueue( workInProgress, - queue, props, instance, renderExpirationTime ) { + // This is always non-null on a ClassComponent or HostRoot + var queue = workInProgress.updateQueue; hasForceUpdate = false; - queue = ensureWorkInProgressQueueIsAClone(workInProgress, queue); { - currentlyProcessingQueue = queue; - } // These values may change as we process the queue. + currentlyProcessingQueue = queue.shared; + } // The last rebase update that is NOT part of the base state. + + var baseQueue = queue.baseQueue; // The last pending update that hasn't been processed yet. - var newBaseState = queue.baseState; - var newFirstUpdate = null; - var newExpirationTime = NoWork; // Iterate through the list of updates to compute the result. + var pendingQueue = queue.shared.pending; - var update = queue.firstUpdate; - var resultState = newBaseState; + if (pendingQueue !== null) { + // We have new updates that haven't been processed yet. + // We'll add them to the base queue. + if (baseQueue !== null) { + // Merge the pending queue and the base queue. + var baseFirst = baseQueue.next; + var pendingFirst = pendingQueue.next; + baseQueue.next = pendingFirst; + pendingQueue.next = baseFirst; + } - while (update !== null) { - var updateExpirationTime = update.expirationTime; + baseQueue = pendingQueue; + queue.shared.pending = null; // TODO: Pass `current` as argument - if (updateExpirationTime < renderExpirationTime) { - // This update does not have sufficient priority. Skip it. - if (newFirstUpdate === null) { - // This is the first skipped update. It will be the first update in - // the new list. - newFirstUpdate = update; // Since this is the first update that was skipped, the current result - // is the new base state. + var current = workInProgress.alternate; - newBaseState = resultState; - } // Since this update will remain in the list, update the remaining - // expiration time. + if (current !== null) { + var currentQueue = current.updateQueue; - if (newExpirationTime < updateExpirationTime) { - newExpirationTime = updateExpirationTime; + if (currentQueue !== null) { + currentQueue.baseQueue = pendingQueue; } - } else { - // This update does have sufficient priority. - // Mark the event time of this update as relevant to this render pass. - // TODO: This should ideally use the true event time of this update rather than - // its priority which is a derived and not reverseable value. - // TODO: We should skip this update if it was already committed but currently - // we have no way of detecting the difference between a committed and suspended - // update here. - markRenderEventTimeAndConfig(updateExpirationTime, update.suspenseConfig); // Process it and compute a new result. - - resultState = getStateFromUpdate( - workInProgress, - queue, - update, - resultState, - props, - instance - ); - var callback = update.callback; + } + } // These values may change as we process the queue. - if (callback !== null) { - workInProgress.effectTag |= Callback; // Set this to null, in case it was mutated during an aborted render. + if (baseQueue !== null) { + var first = baseQueue.next; // Iterate through the list of updates to compute the result. - update.nextEffect = null; + var newState = queue.baseState; + var newExpirationTime = NoWork; + var newBaseState = null; + var newBaseQueueFirst = null; + var newBaseQueueLast = null; - if (queue.lastEffect === null) { - queue.firstEffect = queue.lastEffect = update; - } else { - queue.lastEffect.nextEffect = update; - queue.lastEffect = update; - } - } - } // Continue to the next update. + if (first !== null) { + var update = first; - update = update.next; - } // Separately, iterate though the list of captured updates. + do { + var updateExpirationTime = update.expirationTime; + + if (updateExpirationTime < renderExpirationTime) { + // Priority is insufficient. Skip this update. If this is the first + // skipped update, the previous update/state is the new base + // update/state. + var clone = { + expirationTime: update.expirationTime, + suspenseConfig: update.suspenseConfig, + tag: update.tag, + payload: update.payload, + callback: update.callback, + next: null + }; - var newFirstCapturedUpdate = null; - update = queue.firstCapturedUpdate; + if (newBaseQueueLast === null) { + newBaseQueueFirst = newBaseQueueLast = clone; + newBaseState = newState; + } else { + newBaseQueueLast = newBaseQueueLast.next = clone; + } // Update the remaining priority in the queue. - while (update !== null) { - var _updateExpirationTime = update.expirationTime; + if (updateExpirationTime > newExpirationTime) { + newExpirationTime = updateExpirationTime; + } + } else { + // This update does have sufficient priority. + if (newBaseQueueLast !== null) { + var _clone = { + expirationTime: Sync, + // This update is going to be committed so we never want uncommit it. + suspenseConfig: update.suspenseConfig, + tag: update.tag, + payload: update.payload, + callback: update.callback, + next: null + }; + newBaseQueueLast = newBaseQueueLast.next = _clone; + } // Mark the event time of this update as relevant to this render pass. + // TODO: This should ideally use the true event time of this update rather than + // its priority which is a derived and not reverseable value. + // TODO: We should skip this update if it was already committed but currently + // we have no way of detecting the difference between a committed and suspended + // update here. + + markRenderEventTimeAndConfig( + updateExpirationTime, + update.suspenseConfig + ); // Process this update. + + newState = getStateFromUpdate( + workInProgress, + queue, + update, + newState, + props, + instance + ); + var callback = update.callback; - if (_updateExpirationTime < renderExpirationTime) { - // This update does not have sufficient priority. Skip it. - if (newFirstCapturedUpdate === null) { - // This is the first skipped captured update. It will be the first - // update in the new list. - newFirstCapturedUpdate = update; // If this is the first update that was skipped, the current result is - // the new base state. + if (callback !== null) { + workInProgress.effectTag |= Callback; + var effects = queue.effects; - if (newFirstUpdate === null) { - newBaseState = resultState; + if (effects === null) { + queue.effects = [update]; + } else { + effects.push(update); + } + } } - } // Since this update will remain in the list, update the remaining - // expiration time. - if (newExpirationTime < _updateExpirationTime) { - newExpirationTime = _updateExpirationTime; - } - } else { - // This update does have sufficient priority. Process it and compute - // a new result. - resultState = getStateFromUpdate( - workInProgress, - queue, - update, - resultState, - props, - instance - ); - var _callback = update.callback; + update = update.next; - if (_callback !== null) { - workInProgress.effectTag |= Callback; // Set this to null, in case it was mutated during an aborted render. + if (update === null || update === first) { + pendingQueue = queue.shared.pending; - update.nextEffect = null; - - if (queue.lastCapturedEffect === null) { - queue.firstCapturedEffect = queue.lastCapturedEffect = update; - } else { - queue.lastCapturedEffect.nextEffect = update; - queue.lastCapturedEffect = update; + if (pendingQueue === null) { + break; + } else { + // An update was scheduled from inside a reducer. Add the new + // pending updates to the end of the list and keep processing. + update = baseQueue.next = pendingQueue.next; + pendingQueue.next = first; + queue.baseQueue = baseQueue = pendingQueue; + queue.shared.pending = null; + } } - } + } while (true); } - update = update.next; - } - - if (newFirstUpdate === null) { - queue.lastUpdate = null; - } + if (newBaseQueueLast === null) { + newBaseState = newState; + } else { + newBaseQueueLast.next = newBaseQueueFirst; + } - if (newFirstCapturedUpdate === null) { - queue.lastCapturedUpdate = null; - } else { - workInProgress.effectTag |= Callback; - } + queue.baseState = newBaseState; + queue.baseQueue = newBaseQueueLast; // Set the remaining expiration time to be whatever is remaining in the queue. + // This should be fine because the only two other things that contribute to + // expiration time are props and context. We're already in the middle of the + // begin phase by the time we start processing the queue, so we've already + // dealt with the props. Context in components that specify + // shouldComponentUpdate is tricky; but we'll have to account for + // that regardless. - if (newFirstUpdate === null && newFirstCapturedUpdate === null) { - // We processed every update, without skipping. That means the new base - // state is the same as the result state. - newBaseState = resultState; + markUnprocessedUpdateTime(newExpirationTime); + workInProgress.expirationTime = newExpirationTime; + workInProgress.memoizedState = newState; } - queue.baseState = newBaseState; - queue.firstUpdate = newFirstUpdate; - queue.firstCapturedUpdate = newFirstCapturedUpdate; // Set the remaining expiration time to be whatever is remaining in the queue. - // This should be fine because the only two other things that contribute to - // expiration time are props and context. We're already in the middle of the - // begin phase by the time we start processing the queue, so we've already - // dealt with the props. Context in components that specify - // shouldComponentUpdate is tricky; but we'll have to account for - // that regardless. - - markUnprocessedUpdateTime(newExpirationTime); - workInProgress.expirationTime = newExpirationTime; - workInProgress.memoizedState = resultState; - { currentlyProcessingQueue = null; } @@ -7927,36 +7240,20 @@ function commitUpdateQueue( instance, renderExpirationTime ) { - // If the finished render included captured updates, and there are still - // lower priority updates left over, we need to keep the captured updates - // in the queue so that they are rebased and not dropped once we process the - // queue again at the lower priority. - if (finishedQueue.firstCapturedUpdate !== null) { - // Join the captured update list to the end of the normal list. - if (finishedQueue.lastUpdate !== null) { - finishedQueue.lastUpdate.next = finishedQueue.firstCapturedUpdate; - finishedQueue.lastUpdate = finishedQueue.lastCapturedUpdate; - } // Clear the list of captured updates. - - finishedQueue.firstCapturedUpdate = finishedQueue.lastCapturedUpdate = null; - } // Commit the effects - - commitUpdateEffects(finishedQueue.firstEffect, instance); - finishedQueue.firstEffect = finishedQueue.lastEffect = null; - commitUpdateEffects(finishedQueue.firstCapturedEffect, instance); - finishedQueue.firstCapturedEffect = finishedQueue.lastCapturedEffect = null; -} - -function commitUpdateEffects(effect, instance) { - while (effect !== null) { - var callback = effect.callback; + // Commit the effects + var effects = finishedQueue.effects; + finishedQueue.effects = null; - if (callback !== null) { - effect.callback = null; - callCallback(callback, instance); - } + if (effects !== null) { + for (var i = 0; i < effects.length; i++) { + var effect = effects[i]; + var callback = effect.callback; - effect = effect.nextEffect; + if (callback !== null) { + effect.callback = null; + callCallback(callback, instance); + } + } } } @@ -8001,8 +7298,8 @@ var didWarnAboutInvalidateContextType; if (!didWarnOnInvalidCallback.has(key)) { didWarnOnInvalidCallback.add(key); - warningWithoutStack$1( - false, + + error( "%s(...): Expected the last optional `callback` argument to be a " + "function. Instead received: %s.", callerName, @@ -8017,8 +7314,8 @@ var didWarnAboutInvalidateContextType; if (!didWarnAboutUndefinedDerivedState.has(componentName)) { didWarnAboutUndefinedDerivedState.add(componentName); - warningWithoutStack$1( - false, + + error( "%s.getDerivedStateFromProps(): A valid state object (or null) must be returned. " + "You have returned undefined.", componentName @@ -8075,9 +7372,9 @@ function applyDerivedStateFromProps( workInProgress.memoizedState = memoizedState; // Once the update queue is empty, persist the derived state onto the // base state. - var updateQueue = workInProgress.updateQueue; - - if (updateQueue !== null && workInProgress.expirationTime === NoWork) { + if (workInProgress.expirationTime === NoWork) { + // Queue is always non-null for classes + var updateQueue = workInProgress.updateQueue; updateQueue.baseState = memoizedState; } } @@ -8176,14 +7473,13 @@ function checkShouldComponentUpdate( stopPhaseTimer(); { - !(shouldUpdate !== undefined) - ? warningWithoutStack$1( - false, - "%s.shouldComponentUpdate(): Returned undefined instead of a " + - "boolean value. Make sure to return true or false.", - getComponentName(ctor) || "Component" - ) - : void 0; + if (shouldUpdate === undefined) { + error( + "%s.shouldComponentUpdate(): Returned undefined instead of a " + + "boolean value. Make sure to return true or false.", + getComponentName(ctor) || "Component" + ); + } } return shouldUpdate; @@ -8207,15 +7503,13 @@ function checkClassInstance(workInProgress, ctor, newProps) { if (!renderPresent) { if (ctor.prototype && typeof ctor.prototype.render === "function") { - warningWithoutStack$1( - false, + error( "%s(...): No `render` method found on the returned component " + "instance: did you accidentally return an object from the constructor?", name ); } else { - warningWithoutStack$1( - false, + error( "%s(...): No `render` method found on the returned component " + "instance: you may have forgotten to define `render`.", name @@ -8223,54 +7517,50 @@ function checkClassInstance(workInProgress, ctor, newProps) { } } - var noGetInitialStateOnES6 = - !instance.getInitialState || - instance.getInitialState.isReactClassApproved || - instance.state; - !noGetInitialStateOnES6 - ? warningWithoutStack$1( - false, - "getInitialState was defined on %s, a plain JavaScript class. " + - "This is only supported for classes created using React.createClass. " + - "Did you mean to define a state property instead?", - name - ) - : void 0; - var noGetDefaultPropsOnES6 = - !instance.getDefaultProps || - instance.getDefaultProps.isReactClassApproved; - !noGetDefaultPropsOnES6 - ? warningWithoutStack$1( - false, - "getDefaultProps was defined on %s, a plain JavaScript class. " + - "This is only supported for classes created using React.createClass. " + - "Use a static property to define defaultProps instead.", - name - ) - : void 0; - var noInstancePropTypes = !instance.propTypes; - !noInstancePropTypes - ? warningWithoutStack$1( - false, - "propTypes was defined as an instance property on %s. Use a static " + - "property to define propTypes instead.", - name - ) - : void 0; - var noInstanceContextType = !instance.contextType; - !noInstanceContextType - ? warningWithoutStack$1( - false, - "contextType was defined as an instance property on %s. Use a static " + - "property to define contextType instead.", - name - ) - : void 0; + if ( + instance.getInitialState && + !instance.getInitialState.isReactClassApproved && + !instance.state + ) { + error( + "getInitialState was defined on %s, a plain JavaScript class. " + + "This is only supported for classes created using React.createClass. " + + "Did you mean to define a state property instead?", + name + ); + } + + if ( + instance.getDefaultProps && + !instance.getDefaultProps.isReactClassApproved + ) { + error( + "getDefaultProps was defined on %s, a plain JavaScript class. " + + "This is only supported for classes created using React.createClass. " + + "Use a static property to define defaultProps instead.", + name + ); + } + + if (instance.propTypes) { + error( + "propTypes was defined as an instance property on %s. Use a static " + + "property to define propTypes instead.", + name + ); + } + + if (instance.contextType) { + error( + "contextType was defined as an instance property on %s. Use a static " + + "property to define contextType instead.", + name + ); + } if (disableLegacyContext) { if (ctor.childContextTypes) { - warningWithoutStack$1( - false, + error( "%s uses the legacy childContextTypes API which is no longer supported. " + "Use React.createContext() instead.", name @@ -8278,23 +7568,20 @@ function checkClassInstance(workInProgress, ctor, newProps) { } if (ctor.contextTypes) { - warningWithoutStack$1( - false, + error( "%s uses the legacy contextTypes API which is no longer supported. " + "Use React.createContext() with static contextType instead.", name ); } } else { - var noInstanceContextTypes = !instance.contextTypes; - !noInstanceContextTypes - ? warningWithoutStack$1( - false, - "contextTypes was defined as an instance property on %s. Use a static " + - "property to define contextTypes instead.", - name - ) - : void 0; + if (instance.contextTypes) { + error( + "contextTypes was defined as an instance property on %s. Use a static " + + "property to define contextTypes instead.", + name + ); + } if ( ctor.contextType && @@ -8302,8 +7589,8 @@ function checkClassInstance(workInProgress, ctor, newProps) { !didWarnAboutContextTypeAndContextTypes.has(ctor) ) { didWarnAboutContextTypeAndContextTypes.add(ctor); - warningWithoutStack$1( - false, + + error( "%s declares both contextTypes and contextType static properties. " + "The legacy contextTypes property will be ignored.", name @@ -8311,26 +7598,22 @@ function checkClassInstance(workInProgress, ctor, newProps) { } } - var noComponentShouldUpdate = - typeof instance.componentShouldUpdate !== "function"; - !noComponentShouldUpdate - ? warningWithoutStack$1( - false, - "%s has a method called " + - "componentShouldUpdate(). Did you mean shouldComponentUpdate()? " + - "The name is phrased as a question because the function is " + - "expected to return a value.", - name - ) - : void 0; + if (typeof instance.componentShouldUpdate === "function") { + error( + "%s has a method called " + + "componentShouldUpdate(). Did you mean shouldComponentUpdate()? " + + "The name is phrased as a question because the function is " + + "expected to return a value.", + name + ); + } if ( ctor.prototype && ctor.prototype.isPureReactComponent && typeof instance.shouldComponentUpdate !== "undefined" ) { - warningWithoutStack$1( - false, + error( "%s has a method called shouldComponentUpdate(). " + "shouldComponentUpdate should not be used when extending React.PureComponent. " + "Please extend React.Component if shouldComponentUpdate is used.", @@ -8338,70 +7621,61 @@ function checkClassInstance(workInProgress, ctor, newProps) { ); } - var noComponentDidUnmount = - typeof instance.componentDidUnmount !== "function"; - !noComponentDidUnmount - ? warningWithoutStack$1( - false, - "%s has a method called " + - "componentDidUnmount(). But there is no such lifecycle method. " + - "Did you mean componentWillUnmount()?", - name - ) - : void 0; - var noComponentDidReceiveProps = - typeof instance.componentDidReceiveProps !== "function"; - !noComponentDidReceiveProps - ? warningWithoutStack$1( - false, - "%s has a method called " + - "componentDidReceiveProps(). But there is no such lifecycle method. " + - "If you meant to update the state in response to changing props, " + - "use componentWillReceiveProps(). If you meant to fetch data or " + - "run side-effects or mutations after React has updated the UI, use componentDidUpdate().", - name - ) - : void 0; - var noComponentWillRecieveProps = - typeof instance.componentWillRecieveProps !== "function"; - !noComponentWillRecieveProps - ? warningWithoutStack$1( - false, - "%s has a method called " + - "componentWillRecieveProps(). Did you mean componentWillReceiveProps()?", - name - ) - : void 0; - var noUnsafeComponentWillRecieveProps = - typeof instance.UNSAFE_componentWillRecieveProps !== "function"; - !noUnsafeComponentWillRecieveProps - ? warningWithoutStack$1( - false, - "%s has a method called " + - "UNSAFE_componentWillRecieveProps(). Did you mean UNSAFE_componentWillReceiveProps()?", - name - ) - : void 0; + if (typeof instance.componentDidUnmount === "function") { + error( + "%s has a method called " + + "componentDidUnmount(). But there is no such lifecycle method. " + + "Did you mean componentWillUnmount()?", + name + ); + } + + if (typeof instance.componentDidReceiveProps === "function") { + error( + "%s has a method called " + + "componentDidReceiveProps(). But there is no such lifecycle method. " + + "If you meant to update the state in response to changing props, " + + "use componentWillReceiveProps(). If you meant to fetch data or " + + "run side-effects or mutations after React has updated the UI, use componentDidUpdate().", + name + ); + } + + if (typeof instance.componentWillRecieveProps === "function") { + error( + "%s has a method called " + + "componentWillRecieveProps(). Did you mean componentWillReceiveProps()?", + name + ); + } + + if (typeof instance.UNSAFE_componentWillRecieveProps === "function") { + error( + "%s has a method called " + + "UNSAFE_componentWillRecieveProps(). Did you mean UNSAFE_componentWillReceiveProps()?", + name + ); + } + var hasMutatedProps = instance.props !== newProps; - !(instance.props === undefined || !hasMutatedProps) - ? warningWithoutStack$1( - false, - "%s(...): When calling super() in `%s`, make sure to pass " + - "up the same props that your component's constructor was passed.", - name, - name - ) - : void 0; - var noInstanceDefaultProps = !instance.defaultProps; - !noInstanceDefaultProps - ? warningWithoutStack$1( - false, - "Setting defaultProps as an instance property on %s is not supported and will be ignored." + - " Instead, define defaultProps as a static property on %s.", - name, - name - ) - : void 0; + + if (instance.props !== undefined && hasMutatedProps) { + error( + "%s(...): When calling super() in `%s`, make sure to pass " + + "up the same props that your component's constructor was passed.", + name, + name + ); + } + + if (instance.defaultProps) { + error( + "Setting defaultProps as an instance property on %s is not supported and will be ignored." + + " Instead, define defaultProps as a static property on %s.", + name, + name + ); + } if ( typeof instance.getSnapshotBeforeUpdate === "function" && @@ -8409,63 +7683,53 @@ function checkClassInstance(workInProgress, ctor, newProps) { !didWarnAboutGetSnapshotBeforeUpdateWithoutDidUpdate.has(ctor) ) { didWarnAboutGetSnapshotBeforeUpdateWithoutDidUpdate.add(ctor); - warningWithoutStack$1( - false, + + error( "%s: getSnapshotBeforeUpdate() should be used with componentDidUpdate(). " + "This component defines getSnapshotBeforeUpdate() only.", getComponentName(ctor) ); } - var noInstanceGetDerivedStateFromProps = - typeof instance.getDerivedStateFromProps !== "function"; - !noInstanceGetDerivedStateFromProps - ? warningWithoutStack$1( - false, - "%s: getDerivedStateFromProps() is defined as an instance method " + - "and will be ignored. Instead, declare it as a static method.", - name - ) - : void 0; - var noInstanceGetDerivedStateFromCatch = - typeof instance.getDerivedStateFromError !== "function"; - !noInstanceGetDerivedStateFromCatch - ? warningWithoutStack$1( - false, - "%s: getDerivedStateFromError() is defined as an instance method " + - "and will be ignored. Instead, declare it as a static method.", - name - ) - : void 0; - var noStaticGetSnapshotBeforeUpdate = - typeof ctor.getSnapshotBeforeUpdate !== "function"; - !noStaticGetSnapshotBeforeUpdate - ? warningWithoutStack$1( - false, - "%s: getSnapshotBeforeUpdate() is defined as a static method " + - "and will be ignored. Instead, declare it as an instance method.", - name - ) - : void 0; - var _state = instance.state; + if (typeof instance.getDerivedStateFromProps === "function") { + error( + "%s: getDerivedStateFromProps() is defined as an instance method " + + "and will be ignored. Instead, declare it as a static method.", + name + ); + } - if (_state && (typeof _state !== "object" || isArray$1(_state))) { - warningWithoutStack$1( - false, - "%s.state: must be set to an object or null", + if (typeof instance.getDerivedStateFromError === "function") { + error( + "%s: getDerivedStateFromError() is defined as an instance method " + + "and will be ignored. Instead, declare it as a static method.", name ); } - if (typeof instance.getChildContext === "function") { - !(typeof ctor.childContextTypes === "object") - ? warningWithoutStack$1( - false, - "%s.getChildContext(): childContextTypes must be defined in order to " + - "use getChildContext().", - name - ) - : void 0; + if (typeof ctor.getSnapshotBeforeUpdate === "function") { + error( + "%s: getSnapshotBeforeUpdate() is defined as a static method " + + "and will be ignored. Instead, declare it as an instance method.", + name + ); + } + + var _state = instance.state; + + if (_state && (typeof _state !== "object" || isArray$1(_state))) { + error("%s.state: must be set to an object or null", name); + } + + if ( + typeof instance.getChildContext === "function" && + typeof ctor.childContextTypes !== "object" + ) { + error( + "%s.getChildContext(): childContextTypes must be defined in order to " + + "use getChildContext().", + name + ); } } } @@ -8524,8 +7788,7 @@ function constructClassInstance( "}."; } - warningWithoutStack$1( - false, + error( "%s defines an invalid contextType. " + "contextType should point to the Context object returned by React.createContext().%s", getComponentName(ctor) || "Component", @@ -8569,8 +7832,8 @@ function constructClassInstance( if (!didWarnAboutUninitializedState.has(componentName)) { didWarnAboutUninitializedState.add(componentName); - warningWithoutStack$1( - false, + + error( "`%s` uses `getDerivedStateFromProps` but its initial state is " + "%s. This is not recommended. Instead, define the initial state by " + "assigning an object to `this.state` in the constructor of `%s`. " + @@ -8635,8 +7898,8 @@ function constructClassInstance( if (!didWarnAboutLegacyLifecyclesAndDerivedState.has(_componentName)) { didWarnAboutLegacyLifecyclesAndDerivedState.add(_componentName); - warningWithoutStack$1( - false, + + error( "Unsafe legacy lifecycles will not be called for components using new component APIs.\n\n" + "%s uses %s but also contains the following legacy lifecycles:%s%s%s\n\n" + "The above lifecycles should be removed. Learn more about this warning here:\n" + @@ -8678,8 +7941,7 @@ function callComponentWillMount(workInProgress, instance) { if (oldState !== instance.state) { { - warningWithoutStack$1( - false, + error( "%s.componentWillMount(): Assigning directly to this.state is " + "deprecated (except inside a component's " + "constructor). Use setState instead.", @@ -8716,8 +7978,8 @@ function callComponentWillReceiveProps( if (!didWarnAboutStateAssignmentForComponent.has(componentName)) { didWarnAboutStateAssignmentForComponent.add(componentName); - warningWithoutStack$1( - false, + + error( "%s.componentWillReceiveProps(): Assigning directly to " + "this.state is deprecated (except inside a component's " + "constructor). Use setState instead.", @@ -8744,6 +8006,7 @@ function mountClassInstance( instance.props = newProps; instance.state = workInProgress.memoizedState; instance.refs = emptyRefsObject; + initializeUpdateQueue(workInProgress); var contextType = ctor.contextType; if (typeof contextType === "object" && contextType !== null) { @@ -8761,8 +8024,8 @@ function mountClassInstance( if (!didWarnAboutDirectlyAssigningPropsToState.has(componentName)) { didWarnAboutDirectlyAssigningPropsToState.add(componentName); - warningWithoutStack$1( - false, + + error( "%s: It is not recommended to assign props directly to state " + "because updates to props won't be reflected in state. " + "In most cases, it is better to use props directly.", @@ -8786,19 +8049,8 @@ function mountClassInstance( } } - var updateQueue = workInProgress.updateQueue; - - if (updateQueue !== null) { - processUpdateQueue( - workInProgress, - updateQueue, - newProps, - instance, - renderExpirationTime - ); - instance.state = workInProgress.memoizedState; - } - + processUpdateQueue(workInProgress, newProps, instance, renderExpirationTime); + instance.state = workInProgress.memoizedState; var getDerivedStateFromProps = ctor.getDerivedStateFromProps; if (typeof getDerivedStateFromProps === "function") { @@ -8821,18 +8073,13 @@ function mountClassInstance( callComponentWillMount(workInProgress, instance); // If we had additional state updates during this life-cycle, let's // process them now. - updateQueue = workInProgress.updateQueue; - - if (updateQueue !== null) { - processUpdateQueue( - workInProgress, - updateQueue, - newProps, - instance, - renderExpirationTime - ); - instance.state = workInProgress.memoizedState; - } + processUpdateQueue( + workInProgress, + newProps, + instance, + renderExpirationTime + ); + instance.state = workInProgress.memoizedState; } if (typeof instance.componentDidMount === "function") { @@ -8891,18 +8138,8 @@ function resumeMountClassInstance( resetHasForceUpdateBeforeProcessing(); var oldState = workInProgress.memoizedState; var newState = (instance.state = oldState); - var updateQueue = workInProgress.updateQueue; - - if (updateQueue !== null) { - processUpdateQueue( - workInProgress, - updateQueue, - newProps, - instance, - renderExpirationTime - ); - newState = workInProgress.memoizedState; - } + processUpdateQueue(workInProgress, newProps, instance, renderExpirationTime); + newState = workInProgress.memoizedState; if ( oldProps === newProps && @@ -8992,6 +8229,7 @@ function updateClassInstance( renderExpirationTime ) { var instance = workInProgress.stateNode; + cloneUpdateQueue(current, workInProgress); var oldProps = workInProgress.memoizedProps; instance.props = workInProgress.type === workInProgress.elementType @@ -9035,18 +8273,8 @@ function updateClassInstance( resetHasForceUpdateBeforeProcessing(); var oldState = workInProgress.memoizedState; var newState = (instance.state = oldState); - var updateQueue = workInProgress.updateQueue; - - if (updateQueue !== null) { - processUpdateQueue( - workInProgress, - updateQueue, - newProps, - instance, - renderExpirationTime - ); - newState = workInProgress.memoizedState; - } + processUpdateQueue(workInProgress, newProps, instance, renderExpirationTime); + newState = workInProgress.memoizedState; if ( oldProps === newProps && @@ -9208,8 +8436,8 @@ var warnForMissingKey = function(child) {}; } ownerHasKeyUseWarning[currentComponentErrorInfo] = true; - warning$1( - false, + + error( "Each child in a list should have a unique " + '"key" prop. See https://fb.me/react-warning-keys for ' + "more information." @@ -9235,8 +8463,7 @@ function coerceRef(returnFiber, current$$1, element) { if (!didWarnAboutStringRefs[componentName]) { if (warnAboutStringRefs) { - warningWithoutStack$1( - false, + error( 'Component "%s" contains the string ref "%s". Support for string refs ' + "will be removed in a future major release. We recommend using " + "useRef() or createRef() instead. " + @@ -9247,8 +8474,7 @@ function coerceRef(returnFiber, current$$1, element) { getStackByFiberInDevAndProd(returnFiber) ); } else { - warningWithoutStack$1( - false, + error( 'A string ref, "%s", has been found within a strict mode tree. ' + "String refs are a source of potential bugs and should be avoided. " + "We recommend using useRef() or createRef() instead. " + @@ -9361,23 +8587,25 @@ function throwOnInvalidObjectType(returnFiber, newChild) { } function warnOnFunctionType() { - var currentComponentErrorInfo = - "Functions are not valid as a React child. This may happen if " + - "you return a Component instead of from render. " + - "Or maybe you meant to call this function rather than return it." + - getCurrentFiberStackInDev(); + { + var currentComponentErrorInfo = + "Functions are not valid as a React child. This may happen if " + + "you return a Component instead of from render. " + + "Or maybe you meant to call this function rather than return it." + + getCurrentFiberStackInDev(); - if (ownerHasFunctionTypeWarning[currentComponentErrorInfo]) { - return; - } + if (ownerHasFunctionTypeWarning[currentComponentErrorInfo]) { + return; + } - ownerHasFunctionTypeWarning[currentComponentErrorInfo] = true; - warning$1( - false, - "Functions are not valid as a React child. This may happen if " + - "you return a Component instead of from render. " + - "Or maybe you meant to call this function rather than return it." - ); + ownerHasFunctionTypeWarning[currentComponentErrorInfo] = true; + + error( + "Functions are not valid as a React child. This may happen if " + + "you return a Component instead of from render. " + + "Or maybe you meant to call this function rather than return it." + ); + } } // This wrapper function exists because I expect to clone the code in each path // to be able to optimize each path individually by branching early. This needs // a compiler or we can do it manually. Helpers that don't need this branching @@ -9506,44 +8734,62 @@ function ChildReconciler(shouldTrackSideEffects) { ); created.return = returnFiber; return created; - } else { - // Update - var existing = useFiber(current$$1, textContent, expirationTime); - existing.return = returnFiber; - return existing; - } - } - - function updateElement(returnFiber, current$$1, element, expirationTime) { - if ( - current$$1 !== null && - (current$$1.elementType === element.type || // Keep this check inline so it only runs on the false path: - isCompatibleFamilyForHotReloading(current$$1, element)) - ) { - // Move based on index - var existing = useFiber(current$$1, element.props, expirationTime); - existing.ref = coerceRef(returnFiber, current$$1, element); - existing.return = returnFiber; - - { - existing._debugSource = element._source; - existing._debugOwner = element._owner; - } - - return existing; - } else { - // Insert - var created = createFiberFromElement( - element, - returnFiber.mode, - expirationTime - ); - created.ref = coerceRef(returnFiber, current$$1, element); - created.return = returnFiber; - return created; + } else { + // Update + var existing = useFiber(current$$1, textContent, expirationTime); + existing.return = returnFiber; + return existing; } } + function updateElement(returnFiber, current$$1, element, expirationTime) { + if (current$$1 !== null) { + if ( + current$$1.elementType === element.type || // Keep this check inline so it only runs on the false path: + isCompatibleFamilyForHotReloading(current$$1, element) + ) { + // Move based on index + var existing = useFiber(current$$1, element.props, expirationTime); + existing.ref = coerceRef(returnFiber, current$$1, element); + existing.return = returnFiber; + + { + existing._debugSource = element._source; + existing._debugOwner = element._owner; + } + + return existing; + } else if ( + enableChunksAPI && + current$$1.tag === Chunk && + element.type.$$typeof === REACT_CHUNK_TYPE && + element.type.render === current$$1.type.render + ) { + // Same as above but also update the .type field. + var _existing = useFiber(current$$1, element.props, expirationTime); + + _existing.return = returnFiber; + _existing.type = element.type; + + { + _existing._debugSource = element._source; + _existing._debugOwner = element._owner; + } + + return _existing; + } + } // Insert + + var created = createFiberFromElement( + element, + returnFiber.mode, + expirationTime + ); + created.ref = coerceRef(returnFiber, current$$1, element); + created.return = returnFiber; + return created; + } + function updatePortal(returnFiber, current$$1, portal, expirationTime) { if ( current$$1 === null || @@ -9859,8 +9105,7 @@ function ChildReconciler(shouldTrackSideEffects) { break; } - warning$1( - false, + error( "Encountered two children with the same key, `%s`. " + "Keys should be unique so that components maintain their identity " + "across updates. Non-unique keys may cause children to be " + @@ -9868,6 +9113,7 @@ function ChildReconciler(shouldTrackSideEffects) { "could change in a future version.", key ); + break; default: @@ -10073,28 +9319,28 @@ function ChildReconciler(shouldTrackSideEffects) { typeof Symbol === "function" && // $FlowFixMe Flow doesn't know about toStringTag newChildrenIterable[Symbol.toStringTag] === "Generator" ) { - !didWarnAboutGenerators - ? warning$1( - false, - "Using Generators as children is unsupported and will likely yield " + - "unexpected results because enumerating a generator mutates it. " + - "You may convert it to an array with `Array.from()` or the " + - "`[...spread]` operator before rendering. Keep in mind " + - "you might need to polyfill these features for older browsers." - ) - : void 0; + if (!didWarnAboutGenerators) { + error( + "Using Generators as children is unsupported and will likely yield " + + "unexpected results because enumerating a generator mutates it. " + + "You may convert it to an array with `Array.from()` or the " + + "`[...spread]` operator before rendering. Keep in mind " + + "you might need to polyfill these features for older browsers." + ); + } + didWarnAboutGenerators = true; } // Warn about using Maps as children if (newChildrenIterable.entries === iteratorFn) { - !didWarnAboutMaps - ? warning$1( - false, - "Using Maps as children is unsupported and will likely yield " + - "unexpected results. Convert it to a sequence/iterable of keyed " + - "ReactElements instead." - ) - : void 0; + if (!didWarnAboutMaps) { + error( + "Using Maps as children is unsupported and will likely yield " + + "unexpected results. Convert it to a sequence/iterable of keyed " + + "ReactElements instead." + ); + } + didWarnAboutMaps = true; } // First, validate keys. // We'll get a different iterator later for the main pass. @@ -10302,33 +9548,79 @@ function ChildReconciler(shouldTrackSideEffects) { // TODO: If key === null and child.key === null, then this only applies to // the first item in the list. if (child.key === key) { - if ( - child.tag === Fragment - ? element.type === REACT_FRAGMENT_TYPE - : child.elementType === element.type || // Keep this check inline so it only runs on the false path: + switch (child.tag) { + case Fragment: { + if (element.type === REACT_FRAGMENT_TYPE) { + deleteRemainingChildren(returnFiber, child.sibling); + var existing = useFiber( + child, + element.props.children, + expirationTime + ); + existing.return = returnFiber; + + { + existing._debugSource = element._source; + existing._debugOwner = element._owner; + } + + return existing; + } + + break; + } + + case Chunk: + if (enableChunksAPI) { + if ( + element.type.$$typeof === REACT_CHUNK_TYPE && + element.type.render === child.type.render + ) { + deleteRemainingChildren(returnFiber, child.sibling); + + var _existing2 = useFiber(child, element.props, expirationTime); + + _existing2.type = element.type; + _existing2.return = returnFiber; + + { + _existing2._debugSource = element._source; + _existing2._debugOwner = element._owner; + } + + return _existing2; + } + } + + // We intentionally fallthrough here if enableChunksAPI is not on. + // eslint-disable-next-lined no-fallthrough + + default: { + if ( + child.elementType === element.type || // Keep this check inline so it only runs on the false path: isCompatibleFamilyForHotReloading(child, element) - ) { - deleteRemainingChildren(returnFiber, child.sibling); - var existing = useFiber( - child, - element.type === REACT_FRAGMENT_TYPE - ? element.props.children - : element.props, - expirationTime - ); - existing.ref = coerceRef(returnFiber, child, element); - existing.return = returnFiber; + ) { + deleteRemainingChildren(returnFiber, child.sibling); - { - existing._debugSource = element._source; - existing._debugOwner = element._owner; + var _existing3 = useFiber(child, element.props, expirationTime); + + _existing3.ref = coerceRef(returnFiber, child, element); + _existing3.return = returnFiber; + + { + _existing3._debugSource = element._source; + _existing3._debugOwner = element._owner; + } + + return _existing3; + } + + break; } + } // Didn't match. - return existing; - } else { - deleteRemainingChildren(returnFiber, child); - break; - } + deleteRemainingChildren(returnFiber, child); + break; } else { deleteChild(returnFiber, child); } @@ -10784,7 +10076,7 @@ function createResponderInstance( }; } -function mountEventResponder$1( +function mountEventResponder( responder, responderProps, fiber, @@ -10823,7 +10115,7 @@ function mountEventResponder$1( } } - mountResponderInstance( + DEPRECATED_mountResponderInstance( responder, responderInstance, responderProps, @@ -10859,8 +10151,7 @@ function updateEventListener( if (visistedResponders.has(responder)) { // show warning { - warning$1( - false, + error( 'Duplicate event responder "%s" found in event listeners. ' + "Event listeners passed to elements cannot use the same event responder more than once.", responder.displayName @@ -10875,7 +10166,7 @@ function updateEventListener( if (responderInstance === undefined) { // Mount (happens in either complete or commit phase) - mountEventResponder$1( + mountEventResponder( responder, listenerProps, fiber, @@ -10889,7 +10180,11 @@ function updateEventListener( } } -function updateEventListeners(listeners, fiber, rootContainerInstance) { +function updateDeprecatedEventListeners( + listeners, + fiber, + rootContainerInstance +) { var visistedResponders = new Set(); var dependencies = fiber.dependencies; @@ -10905,7 +10200,7 @@ function updateEventListeners(listeners, fiber, rootContainerInstance) { var respondersMap = dependencies.responders; if (respondersMap === null) { - respondersMap = new Map(); + dependencies.responders = respondersMap = new Map(); } if (isArray$2(listeners)) { @@ -10943,7 +10238,7 @@ function updateEventListeners(listeners, fiber, rootContainerInstance) { if (!visistedResponders.has(mountedResponder)) { var responderInstance = _respondersMap.get(mountedResponder); - unmountResponderInstance(responderInstance); + DEPRECATED_unmountResponderInstance(responderInstance); _respondersMap.delete(mountedResponder); } @@ -10951,7 +10246,7 @@ function updateEventListeners(listeners, fiber, rootContainerInstance) { } } } -function createResponderListener(responder, props) { +function createDeprecatedResponderListener(responder, props) { var eventResponderListener = { responder: responder, props: props @@ -10963,6 +10258,24 @@ function createResponderListener(responder, props) { return eventResponderListener; } +function unmountDeprecatedResponderListeners(fiber) { + var dependencies = fiber.dependencies; + + if (dependencies !== null) { + var respondersMap = dependencies.responders; + + if (respondersMap !== null) { + var responderInstances = Array.from(respondersMap.values()); + + for (var i = 0, length = responderInstances.length; i < length; i++) { + var responderInstance = responderInstances[i]; + DEPRECATED_unmountResponderInstance(responderInstance); + } + + dependencies.responders = null; + } + } +} var NoEffect$1 = /* */ @@ -11007,13 +10320,7 @@ var currentlyRenderingFiber$1 = null; // Hooks are stored as a linked list on th // work-in-progress fiber. var currentHook = null; -var nextCurrentHook = null; -var firstWorkInProgressHook = null; -var workInProgressHook = null; -var nextWorkInProgressHook = null; -var remainingExpirationTime = NoWork; -var componentUpdateQueue = null; -var sideEffectTag = 0; // Updates scheduled during render will trigger an immediate re-render at the +var workInProgressHook = null; // Updates scheduled during render will trigger an immediate re-render at the // end of the current pass. We can't store these updates on the normal queue, // because if the work is aborted, they should be discarded. Because this is // a relatively rare case, we also don't want to add an additional field to @@ -11071,8 +10378,7 @@ function checkDepsAreArrayDev(deps) { if (deps !== undefined && deps !== null && !Array.isArray(deps)) { // Verify deps, but only on mount to avoid extra checks. // It's unlikely their type would change as usually you define them inline. - warning$1( - false, + error( "%s received a final argument that is not an array (instead, received `%s`). When " + "specified, the final argument must be an array.", currentHookNameInDev, @@ -11108,8 +10414,7 @@ function warnOnHookMismatchInDev(currentHookName) { table += row; } - warning$1( - false, + error( "React has detected a change in the order of Hooks called by %s. " + "This will lead to bugs and errors if not fixed. " + "For more information, read the Rules of Hooks: https://fb.me/rules-of-hooks\n\n" + @@ -11143,8 +10448,7 @@ function areHookInputsEqual(nextDeps, prevDeps) { if (prevDeps === null) { { - warning$1( - false, + error( "%s received a final argument during this render, but not during " + "the previous render. Even though the final argument is optional, " + "its type cannot change between renders.", @@ -11159,8 +10463,7 @@ function areHookInputsEqual(nextDeps, prevDeps) { // Don't bother comparing lengths in prod because these arrays should be // passed inline. if (nextDeps.length !== prevDeps.length) { - warning$1( - false, + error( "The final argument passed to %s changed size between renders. The " + "order and size of this array must remain constant.\n\n" + "Previous: %s\n" + @@ -11188,12 +10491,11 @@ function renderWithHooks( workInProgress, Component, props, - refOrContext, + secondArg, nextRenderExpirationTime ) { renderExpirationTime$1 = nextRenderExpirationTime; currentlyRenderingFiber$1 = workInProgress; - nextCurrentHook = current !== null ? current.memoizedState : null; { hookTypesDev = current !== null ? current._debugHookTypes : null; @@ -11201,24 +10503,25 @@ function renderWithHooks( ignorePreviousDependencies = current !== null && current.type !== workInProgress.type; - } // The following should have already been reset + } + + workInProgress.memoizedState = null; + workInProgress.updateQueue = null; + workInProgress.expirationTime = NoWork; // The following should have already been reset // currentHook = null; // workInProgressHook = null; - // remainingExpirationTime = NoWork; - // componentUpdateQueue = null; // didScheduleRenderPhaseUpdate = false; // renderPhaseUpdates = null; // numberOfReRenders = 0; - // sideEffectTag = 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 nextCurrentHook === null. + // 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) - // Using nextCurrentHook to differentiate between mount/update only works if at least one stateful hook is used. + // Using memoizedState to differentiate between mount/update only works if at least one stateful hook is used. // Non-stateful hooks (e.g. context) don't get added to memoizedState, - // so nextCurrentHook would be null during updates and mounts. + // so memoizedState would be null during updates and mounts. { - if (nextCurrentHook !== null) { + if (current !== null && current.memoizedState !== null) { ReactCurrentDispatcher$1.current = HooksDispatcherOnUpdateInDEV; } else if (hookTypesDev !== null) { // This dispatcher handles an edge case where a component is updating, @@ -11232,7 +10535,7 @@ function renderWithHooks( } } - var children = Component(props, refOrContext); + var children = Component(props, secondArg); if (didScheduleRenderPhaseUpdate) { do { @@ -11245,11 +10548,9 @@ function renderWithHooks( ignorePreviousDependencies = false; } // Start over from the beginning of the list - nextCurrentHook = current !== null ? current.memoizedState : null; - nextWorkInProgressHook = firstWorkInProgressHook; currentHook = null; workInProgressHook = null; - componentUpdateQueue = null; + workInProgress.updateQueue = null; { // Also validate hook order for cascading updates. @@ -11257,7 +10558,7 @@ function renderWithHooks( } ReactCurrentDispatcher$1.current = HooksDispatcherOnUpdateInDEV; - children = Component(props, refOrContext); + children = Component(props, secondArg); } while (didScheduleRenderPhaseUpdate); renderPhaseUpdates = null; @@ -11266,14 +10567,9 @@ function renderWithHooks( // at the beginning of the render phase and there's no re-entrancy. ReactCurrentDispatcher$1.current = ContextOnlyDispatcher; - var renderedWork = currentlyRenderingFiber$1; - renderedWork.memoizedState = firstWorkInProgressHook; - renderedWork.expirationTime = remainingExpirationTime; - renderedWork.updateQueue = componentUpdateQueue; - renderedWork.effectTag |= sideEffectTag; { - renderedWork._debugHookTypes = hookTypesDev; + workInProgress._debugHookTypes = hookTypesDev; } // This check uses currentHook so that it works the same in DEV and prod bundles. // hookTypesDev could catch more cases (e.g. context) but only in DEV bundles. @@ -11281,20 +10577,13 @@ function renderWithHooks( renderExpirationTime$1 = NoWork; currentlyRenderingFiber$1 = null; currentHook = null; - nextCurrentHook = null; - firstWorkInProgressHook = null; workInProgressHook = null; - nextWorkInProgressHook = null; { currentHookNameInDev = null; hookTypesDev = null; hookTypesUpdateIndexDev = -1; - } - - remainingExpirationTime = NoWork; - componentUpdateQueue = null; - sideEffectTag = 0; // These were reset above + } // These were reset above // didScheduleRenderPhaseUpdate = false; // renderPhaseUpdates = null; // numberOfReRenders = 0; @@ -11325,10 +10614,7 @@ function resetHooks() { renderExpirationTime$1 = NoWork; currentlyRenderingFiber$1 = null; currentHook = null; - nextCurrentHook = null; - firstWorkInProgressHook = null; workInProgressHook = null; - nextWorkInProgressHook = null; { hookTypesDev = null; @@ -11336,9 +10622,6 @@ function resetHooks() { currentHookNameInDev = null; } - remainingExpirationTime = NoWork; - componentUpdateQueue = null; - sideEffectTag = 0; didScheduleRenderPhaseUpdate = false; renderPhaseUpdates = null; numberOfReRenders = 0; @@ -11348,14 +10631,14 @@ function mountWorkInProgressHook() { var hook = { memoizedState: null, baseState: null, + baseQueue: null, queue: null, - baseUpdate: null, next: null }; if (workInProgressHook === null) { // This is the first hook in the list - firstWorkInProgressHook = workInProgressHook = hook; + currentlyRenderingFiber$1.memoizedState = workInProgressHook = hook; } else { // Append to the end of the list workInProgressHook = workInProgressHook.next = hook; @@ -11370,12 +10653,33 @@ function updateWorkInProgressHook() { // clone, or a work-in-progress hook from a previous render pass that we can // use as a base. When we reach the end of the base list, we must switch to // the dispatcher used for mounts. + var nextCurrentHook; + + if (currentHook === null) { + var current = currentlyRenderingFiber$1.alternate; + + if (current !== null) { + nextCurrentHook = current.memoizedState; + } else { + nextCurrentHook = null; + } + } else { + nextCurrentHook = currentHook.next; + } + + var nextWorkInProgressHook; + + if (workInProgressHook === null) { + nextWorkInProgressHook = currentlyRenderingFiber$1.memoizedState; + } else { + nextWorkInProgressHook = workInProgressHook.next; + } + if (nextWorkInProgressHook !== null) { // There's already a work-in-progress. Reuse it. workInProgressHook = nextWorkInProgressHook; nextWorkInProgressHook = workInProgressHook.next; currentHook = nextCurrentHook; - nextCurrentHook = currentHook !== null ? currentHook.next : null; } else { // Clone from the current hook. if (!(nextCurrentHook !== null)) { @@ -11386,20 +10690,18 @@ function updateWorkInProgressHook() { var newHook = { memoizedState: currentHook.memoizedState, baseState: currentHook.baseState, + baseQueue: currentHook.baseQueue, queue: currentHook.queue, - baseUpdate: currentHook.baseUpdate, next: null }; if (workInProgressHook === null) { // This is the first hook in the list. - workInProgressHook = firstWorkInProgressHook = newHook; + currentlyRenderingFiber$1.memoizedState = workInProgressHook = newHook; } else { // Append to the end of the list. workInProgressHook = workInProgressHook.next = newHook; } - - nextCurrentHook = currentHook.next; } return workInProgressHook; @@ -11427,13 +10729,13 @@ function mountReducer(reducer, initialArg, init) { hook.memoizedState = hook.baseState = initialState; var queue = (hook.queue = { - last: null, + pending: null, dispatch: null, lastRenderedReducer: reducer, lastRenderedState: initialState }); var dispatch = (queue.dispatch = dispatchAction.bind( - null, // Flow doesn't know this is non-null, but we do. + null, currentlyRenderingFiber$1, queue )); @@ -11485,7 +10787,7 @@ function updateReducer(reducer, initialArg, init) { // TODO: Not sure if this is the desired semantics, but it's what we // do for gDSFP. I can't remember why. - if (hook.baseUpdate === queue.last) { + if (hook.baseQueue === null) { hook.baseState = newState; } @@ -11495,35 +10797,37 @@ function updateReducer(reducer, initialArg, init) { } return [hook.memoizedState, _dispatch]; - } // The last update in the entire queue + } - var last = queue.last; // The last update that is part of the base state. + var current = currentHook; // The last rebase update that is NOT part of the base state. - var baseUpdate = hook.baseUpdate; - var baseState = hook.baseState; // Find the first unprocessed update. + var baseQueue = current.baseQueue; // The last pending update that hasn't been processed yet. - var first; + var pendingQueue = queue.pending; - if (baseUpdate !== null) { - if (last !== null) { - // For the first update, the queue is a circular linked list where - // `queue.last.next = queue.first`. Once the first update commits, and - // the `baseUpdate` is no longer empty, we can unravel the list. - last.next = null; + if (pendingQueue !== null) { + // We have new updates that haven't been processed yet. + // We'll add them to the base queue. + if (baseQueue !== null) { + // Merge the pending queue and the base queue. + var baseFirst = baseQueue.next; + var pendingFirst = pendingQueue.next; + baseQueue.next = pendingFirst; + pendingQueue.next = baseFirst; } - first = baseUpdate.next; - } else { - first = last !== null ? last.next : null; + current.baseQueue = baseQueue = pendingQueue; + queue.pending = null; } - if (first !== null) { - var _newState = baseState; + if (baseQueue !== null) { + // We have a queue to process. + var first = baseQueue.next; + var _newState = current.baseState; var newBaseState = null; - var newBaseUpdate = null; - var prevUpdate = baseUpdate; + var newBaseQueueFirst = null; + var newBaseQueueLast = null; var _update = first; - var didSkip = false; do { var updateExpirationTime = _update.expirationTime; @@ -11532,24 +10836,46 @@ function updateReducer(reducer, initialArg, init) { // Priority is insufficient. Skip this update. If this is the first // skipped update, the previous update/state is the new base // update/state. - if (!didSkip) { - didSkip = true; - newBaseUpdate = prevUpdate; + var clone = { + expirationTime: _update.expirationTime, + suspenseConfig: _update.suspenseConfig, + action: _update.action, + eagerReducer: _update.eagerReducer, + eagerState: _update.eagerState, + next: null + }; + + if (newBaseQueueLast === null) { + newBaseQueueFirst = newBaseQueueLast = clone; newBaseState = _newState; + } else { + newBaseQueueLast = newBaseQueueLast.next = clone; } // Update the remaining priority in the queue. - if (updateExpirationTime > remainingExpirationTime) { - remainingExpirationTime = updateExpirationTime; - markUnprocessedUpdateTime(remainingExpirationTime); + if (updateExpirationTime > currentlyRenderingFiber$1.expirationTime) { + currentlyRenderingFiber$1.expirationTime = updateExpirationTime; + markUnprocessedUpdateTime(updateExpirationTime); } } else { // This update does have sufficient priority. - // Mark the event time of this update as relevant to this render pass. + if (newBaseQueueLast !== null) { + var _clone = { + expirationTime: Sync, + // This update is going to be committed so we never want uncommit it. + suspenseConfig: _update.suspenseConfig, + action: _update.action, + eagerReducer: _update.eagerReducer, + eagerState: _update.eagerState, + next: null + }; + newBaseQueueLast = newBaseQueueLast.next = _clone; + } // Mark the event time of this update as relevant to this render pass. // TODO: This should ideally use the true event time of this update rather than // its priority which is a derived and not reverseable value. // TODO: We should skip this update if it was already committed but currently // we have no way of detecting the difference between a committed and suspended // update here. + markRenderEventTimeAndConfig( updateExpirationTime, _update.suspenseConfig @@ -11565,13 +10891,13 @@ function updateReducer(reducer, initialArg, init) { } } - prevUpdate = _update; _update = _update.next; } while (_update !== null && _update !== first); - if (!didSkip) { - newBaseUpdate = prevUpdate; + if (newBaseQueueLast === null) { newBaseState = _newState; + } else { + newBaseQueueLast.next = newBaseQueueFirst; } // Mark that the fiber performed work, but only if the new state is // different from the current state. @@ -11580,8 +10906,8 @@ function updateReducer(reducer, initialArg, init) { } hook.memoizedState = _newState; - hook.baseUpdate = newBaseUpdate; hook.baseState = newBaseState; + hook.baseQueue = newBaseQueueLast; queue.lastRenderedState = _newState; } @@ -11598,13 +10924,13 @@ function mountState(initialState) { hook.memoizedState = hook.baseState = initialState; var queue = (hook.queue = { - last: null, + pending: null, dispatch: null, lastRenderedReducer: basicStateReducer, lastRenderedState: initialState }); var dispatch = (queue.dispatch = dispatchAction.bind( - null, // Flow doesn't know this is non-null, but we do. + null, currentlyRenderingFiber$1, queue )); @@ -11624,9 +10950,11 @@ function pushEffect(tag, create, destroy, deps) { // Circular next: null }; + var componentUpdateQueue = currentlyRenderingFiber$1.updateQueue; if (componentUpdateQueue === null) { componentUpdateQueue = createFunctionComponentUpdateQueue(); + currentlyRenderingFiber$1.updateQueue = componentUpdateQueue; componentUpdateQueue.lastEffect = effect.next = effect; } else { var lastEffect = componentUpdateQueue.lastEffect; @@ -11666,7 +10994,7 @@ function updateRef(initialValue) { function mountEffectImpl(fiberEffectTag, hookEffectTag, create, deps) { var hook = mountWorkInProgressHook(); var nextDeps = deps === undefined ? null : deps; - sideEffectTag |= fiberEffectTag; + currentlyRenderingFiber$1.effectTag |= fiberEffectTag; hook.memoizedState = pushEffect(hookEffectTag, create, undefined, nextDeps); } @@ -11689,7 +11017,7 @@ function updateEffectImpl(fiberEffectTag, hookEffectTag, create, deps) { } } - sideEffectTag |= fiberEffectTag; + currentlyRenderingFiber$1.effectTag |= fiberEffectTag; hook.memoizedState = pushEffect(hookEffectTag, create, destroy, nextDeps); } @@ -11747,14 +11075,13 @@ function imperativeHandleEffect(create, ref) { var refObject = ref; { - !refObject.hasOwnProperty("current") - ? warning$1( - false, - "Expected useImperativeHandle() first argument to either be a " + - "ref callback or React.createRef() object. Instead received: %s.", - "an object with keys {" + Object.keys(refObject).join(", ") + "}" - ) - : void 0; + if (!refObject.hasOwnProperty("current")) { + error( + "Expected useImperativeHandle() first argument to either be a " + + "ref callback or React.createRef() object. Instead received: %s.", + "an object with keys {" + Object.keys(refObject).join(", ") + "}" + ); + } } var _inst2 = create(); @@ -11768,14 +11095,13 @@ function imperativeHandleEffect(create, ref) { function mountImperativeHandle(ref, create, deps) { { - !(typeof create === "function") - ? warning$1( - false, - "Expected useImperativeHandle() second argument to be a function " + - "that creates a handle. Instead received: %s.", - create !== null ? typeof create : "null" - ) - : void 0; + if (typeof create !== "function") { + error( + "Expected useImperativeHandle() second argument to be a function " + + "that creates a handle. Instead received: %s.", + create !== null ? typeof create : "null" + ); + } } // TODO: If deps are provided, should we skip comparing the ref itself? var effectDeps = @@ -11790,14 +11116,13 @@ function mountImperativeHandle(ref, create, deps) { function updateImperativeHandle(ref, create, deps) { { - !(typeof create === "function") - ? warning$1( - false, - "Expected useImperativeHandle() second argument to be a function " + - "that creates a handle. Instead received: %s.", - create !== null ? typeof create : "null" - ) - : void 0; + if (typeof create !== "function") { + error( + "Expected useImperativeHandle() second argument to be a function " + + "that creates a handle. Instead received: %s.", + create !== null ? typeof create : "null" + ); + } } // TODO: If deps are provided, should we skip comparing the ref itself? var effectDeps = @@ -11880,17 +11205,14 @@ function mountDeferredValue(value, config) { mountEffect( function() { - Scheduler.unstable_next(function() { - var previousConfig = ReactCurrentBatchConfig$1.suspense; - ReactCurrentBatchConfig$1.suspense = - config === undefined ? null : config; + var previousConfig = ReactCurrentBatchConfig$1.suspense; + ReactCurrentBatchConfig$1.suspense = config === undefined ? null : config; - try { - setValue(value); - } finally { - ReactCurrentBatchConfig$1.suspense = previousConfig; - } - }); + try { + setValue(value); + } finally { + ReactCurrentBatchConfig$1.suspense = previousConfig; + } }, [value, config] ); @@ -11904,47 +11226,54 @@ function updateDeferredValue(value, config) { updateEffect( function() { - Scheduler.unstable_next(function() { - var previousConfig = ReactCurrentBatchConfig$1.suspense; - ReactCurrentBatchConfig$1.suspense = - config === undefined ? null : config; + var previousConfig = ReactCurrentBatchConfig$1.suspense; + ReactCurrentBatchConfig$1.suspense = config === undefined ? null : config; - try { - setValue(value); - } finally { - ReactCurrentBatchConfig$1.suspense = previousConfig; - } - }); + try { + setValue(value); + } finally { + ReactCurrentBatchConfig$1.suspense = previousConfig; + } }, [value, config] ); return prevValue; } +function startTransition(setPending, config, callback) { + var priorityLevel = getCurrentPriorityLevel(); + runWithPriority( + priorityLevel < UserBlockingPriority ? UserBlockingPriority : priorityLevel, + function() { + setPending(true); + } + ); + runWithPriority( + priorityLevel > NormalPriority ? NormalPriority : priorityLevel, + function() { + var previousConfig = ReactCurrentBatchConfig$1.suspense; + ReactCurrentBatchConfig$1.suspense = config === undefined ? null : config; + + try { + setPending(false); + callback(); + } finally { + ReactCurrentBatchConfig$1.suspense = previousConfig; + } + } + ); +} + function mountTransition(config) { var _mountState2 = mountState(false), isPending = _mountState2[0], setPending = _mountState2[1]; - var startTransition = mountCallback( - function(callback) { - setPending(true); - Scheduler.unstable_next(function() { - var previousConfig = ReactCurrentBatchConfig$1.suspense; - ReactCurrentBatchConfig$1.suspense = - config === undefined ? null : config; - - try { - setPending(false); - callback(); - } finally { - ReactCurrentBatchConfig$1.suspense = previousConfig; - } - }); - }, - [config, isPending] - ); - return [startTransition, isPending]; + var start = mountCallback(startTransition.bind(null, setPending, config), [ + setPending, + config + ]); + return [start, isPending]; } function updateTransition(config) { @@ -11952,25 +11281,11 @@ function updateTransition(config) { isPending = _updateState2[0], setPending = _updateState2[1]; - var startTransition = updateCallback( - function(callback) { - setPending(true); - Scheduler.unstable_next(function() { - var previousConfig = ReactCurrentBatchConfig$1.suspense; - ReactCurrentBatchConfig$1.suspense = - config === undefined ? null : config; - - try { - setPending(false); - callback(); - } finally { - ReactCurrentBatchConfig$1.suspense = previousConfig; - } - }); - }, - [config, isPending] - ); - return [startTransition, isPending]; + var start = updateCallback(startTransition.bind(null, setPending, config), [ + setPending, + config + ]); + return [start, isPending]; } function dispatchAction(fiber, queue, action) { @@ -11981,14 +11296,13 @@ function dispatchAction(fiber, queue, action) { } { - !(typeof arguments[3] !== "function") - ? warning$1( - false, - "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()." - ) - : void 0; + 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()." + ); + } } var alternate = fiber.alternate; @@ -12053,23 +11367,17 @@ function dispatchAction(fiber, queue, action) { _update2.priority = getCurrentPriorityLevel(); } // Append the update to the end of the list. - var last = queue.last; + var pending = queue.pending; - if (last === null) { + if (pending === null) { // This is the first update. Create a circular list. _update2.next = _update2; } else { - var first = last.next; - - if (first !== null) { - // Still circular. - _update2.next = first; - } - - last.next = _update2; + _update2.next = pending.next; + pending.next = _update2; } - queue.last = _update2; + queue.pending = _update2; if ( fiber.expirationTime === NoWork && @@ -12105,7 +11413,7 @@ function dispatchAction(fiber, queue, action) { // time the reducer has changed. return; } - } catch (error) { + } catch (error$$1) { // Suppress the error. It will throw again in the render phase. } finally { { @@ -12151,8 +11459,7 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null; { var warnInvalidContextAccess = function() { - warning$1( - false, + 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 " + @@ -12161,8 +11468,7 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null; }; var warnInvalidHookAccess = function() { - warning$1( - false, + error( "Do not call Hooks inside useEffect(...), useMemo(...), or other built-in Hooks. " + "You can only call Hooks at the top level of your React function. " + "For more information, see " + @@ -12253,7 +11559,7 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null; useResponder: function(responder, props) { currentHookNameInDev = "useResponder"; mountHookTypesDev(); - return createResponderListener(responder, props); + return createDeprecatedResponderListener(responder, props); }, useDeferredValue: function(value, config) { currentHookNameInDev = "useDeferredValue"; @@ -12344,7 +11650,7 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null; useResponder: function(responder, props) { currentHookNameInDev = "useResponder"; updateHookTypesDev(); - return createResponderListener(responder, props); + return createDeprecatedResponderListener(responder, props); }, useDeferredValue: function(value, config) { currentHookNameInDev = "useDeferredValue"; @@ -12435,7 +11741,7 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null; useResponder: function(responder, props) { currentHookNameInDev = "useResponder"; updateHookTypesDev(); - return createResponderListener(responder, props); + return createDeprecatedResponderListener(responder, props); }, useDeferredValue: function(value, config) { currentHookNameInDev = "useDeferredValue"; @@ -12538,7 +11844,7 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null; currentHookNameInDev = "useResponder"; warnInvalidHookAccess(); mountHookTypesDev(); - return createResponderListener(responder, props); + return createDeprecatedResponderListener(responder, props); }, useDeferredValue: function(value, config) { currentHookNameInDev = "useDeferredValue"; @@ -12643,7 +11949,7 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null; currentHookNameInDev = "useResponder"; warnInvalidHookAccess(); updateHookTypesDev(); - return createResponderListener(responder, props); + return createDeprecatedResponderListener(responder, props); }, useDeferredValue: function(value, config) { currentHookNameInDev = "useDeferredValue"; @@ -12723,12 +12029,11 @@ var isHydrating = false; function warnIfHydrating() { { - !!isHydrating - ? warning$1( - false, - "We should not be hydrating here. This is a bug in React. Please file a bug." - ) - : void 0; + if (isHydrating) { + error( + "We should not be hydrating here. This is a bug in React. Please file a bug." + ); + } } } @@ -13255,8 +12560,8 @@ function forceUnmountCurrentAndReconcile( renderExpirationTime ); // 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 their - // identity matches. + // the effect of remounting all children regardless of whether their + // identities match. workInProgress.child = reconcileChildFibers( workInProgress, @@ -13516,7 +12821,7 @@ function updateSimpleMemoComponent( if ( shallowEqual(prevProps, nextProps) && - current$$1.ref === workInProgress.ref && // Prevent bailout if the implementation changed due to hot reload: + current$$1.ref === workInProgress.ref && // Prevent bailout if the implementation changed due to hot reload. workInProgress.type === current$$1.type ) { didReceiveUpdate = false; @@ -13676,6 +12981,73 @@ function updateFunctionComponent( return workInProgress.child; } +function updateChunk( + current$$1, + workInProgress, + chunk, + nextProps, + renderExpirationTime +) { + // 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. + var render = chunk.render; + var data = chunk.query(); // The rest is a fork of updateFunctionComponent + + var nextChildren; + prepareToReadContext(workInProgress, renderExpirationTime); + + { + ReactCurrentOwner$3.current = workInProgress; + setCurrentPhase("render"); + nextChildren = renderWithHooks( + current$$1, + workInProgress, + render, + nextProps, + data, + renderExpirationTime + ); + + if ( + debugRenderPhaseSideEffectsForStrictMode && + workInProgress.mode & StrictMode + ) { + // Only double-render components with Hooks + if (workInProgress.memoizedState !== null) { + nextChildren = renderWithHooks( + current$$1, + workInProgress, + render, + nextProps, + data, + renderExpirationTime + ); + } + } + + setCurrentPhase(null); + } + + if (current$$1 !== null && !didReceiveUpdate) { + bailoutHooks(current$$1, workInProgress, renderExpirationTime); + return bailoutOnAlreadyFinishedWork( + current$$1, + workInProgress, + renderExpirationTime + ); + } // React DevTools reads this flag. + + workInProgress.effectTag |= PerformedWork; + reconcileChildren( + current$$1, + workInProgress, + nextChildren, + renderExpirationTime + ); + return workInProgress.child; +} + function updateClassComponent( current$$1, workInProgress, @@ -13718,9 +13090,9 @@ function updateClassComponent( if (instance === null) { if (current$$1 !== null) { - // An class component without an instance only mounts if it suspended - // inside a non- concurrent tree, in an inconsistent state. We want to - // tree it like a new mount, even though an empty version of it already + // 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$$1.alternate = null; workInProgress.alternate = null; // Since this is conceptually a new fiber, schedule a Placement effect @@ -13772,14 +13144,14 @@ function updateClassComponent( var inst = workInProgress.stateNode; if (inst.props !== nextProps) { - !didWarnAboutReassigningProps - ? warning$1( - false, - "It looks like %s is reassigning its own `this.props` while rendering. " + - "This is not supported and can lead to confusing bugs.", - getComponentName(workInProgress.type) || "a component" - ) - : void 0; + 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.", + getComponentName(workInProgress.type) || "a component" + ); + } + didWarnAboutReassigningProps = true; } } @@ -13821,7 +13193,7 @@ function finishClassComponent( didCaptureError && typeof Component.getDerivedStateFromError !== "function" ) { - // If we captured an error, but getDerivedStateFrom catch is not defined, + // 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. @@ -13900,7 +13272,7 @@ function updateHostRoot(current$$1, workInProgress, renderExpirationTime) { pushHostRootContext(workInProgress); var updateQueue = workInProgress.updateQueue; - if (!(updateQueue !== null)) { + if (!(current$$1 !== 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." ); @@ -13909,13 +13281,8 @@ function updateHostRoot(current$$1, workInProgress, renderExpirationTime) { var nextProps = workInProgress.pendingProps; var prevState = workInProgress.memoizedState; var prevChildren = prevState !== null ? prevState.element : null; - processUpdateQueue( - workInProgress, - updateQueue, - nextProps, - null, - renderExpirationTime - ); + cloneUpdateQueue(current$$1, workInProgress); + processUpdateQueue(workInProgress, nextProps, null, renderExpirationTime); var nextState = workInProgress.memoizedState; // Caution: React DevTools currently depends on this property // being called "element". @@ -13989,7 +13356,7 @@ function updateHostComponent(current$$1, workInProgress, renderExpirationTime) { if (isDirectTextChild) { // We special case a direct text child of a host node. This is a common // case. We won't handle it as a reified child. We will instead handle - // this in the host environment that also have access to this prop. That + // this in the host environment that also has access to this prop. That // avoids allocating another HostText fiber and traversing it. nextChildren = null; } else if (prevProps !== null && shouldSetTextContent(type, prevProps)) { @@ -14039,7 +13406,7 @@ function mountLazyComponent( renderExpirationTime ) { if (_current !== null) { - // An lazy component only mounts if it suspended inside a non- + // 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. @@ -14077,7 +13444,7 @@ function mountLazyComponent( resolvedProps, renderExpirationTime ); - break; + return child; } case ClassComponent: { @@ -14094,7 +13461,7 @@ function mountLazyComponent( resolvedProps, renderExpirationTime ); - break; + return child; } case ForwardRef: { @@ -14111,7 +13478,7 @@ function mountLazyComponent( resolvedProps, renderExpirationTime ); - break; + return child; } case MemoComponent: { @@ -14139,36 +13506,48 @@ function mountLazyComponent( updateExpirationTime, renderExpirationTime ); - break; + return child; } - default: { - 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 Error( - "Element type is invalid. Received a promise that resolves to: " + - Component + - ". Lazy element type must resolve to a class or function." + - hint + case Chunk: { + if (enableChunksAPI) { + // TODO: Resolve for Hot Reloading. + child = updateChunk( + null, + workInProgress, + Component, + props, + renderExpirationTime ); + return child; } + + break; } } - 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 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( @@ -14262,13 +13641,13 @@ function mountIndeterminateComponent( var componentName = getComponentName(Component) || "Unknown"; if (!didWarnAboutBadClass[componentName]) { - warningWithoutStack$1( - false, + 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 ); + didWarnAboutBadClass[componentName] = true; } } @@ -14300,8 +13679,7 @@ function mountIndeterminateComponent( var _componentName = getComponentName(Component) || "Unknown"; if (!didWarnAboutModulePatternComponent[_componentName]) { - warningWithoutStack$1( - false, + 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. " + @@ -14311,6 +13689,7 @@ function mountIndeterminateComponent( _componentName, _componentName ); + didWarnAboutModulePatternComponent[_componentName] = true; } } // Proceed under the assumption that this is a class instance @@ -14332,6 +13711,7 @@ function mountIndeterminateComponent( workInProgress.memoizedState = value.state !== null && value.state !== undefined ? value.state : null; + initializeUpdateQueue(workInProgress); var getDerivedStateFromProps = Component.getDerivedStateFromProps; if (typeof getDerivedStateFromProps === "function") { @@ -14359,8 +13739,7 @@ function mountIndeterminateComponent( { if (disableLegacyContext && Component.contextTypes) { - warningWithoutStack$1( - false, + error( "%s uses the legacy contextTypes API which is no longer supported. " + "Use React.createContext() with React.useContext() instead.", getComponentName(Component) || "Unknown" @@ -14396,86 +13775,87 @@ function mountIndeterminateComponent( } function validateFunctionComponentInDev(workInProgress, Component) { - if (Component) { - !!Component.childContextTypes - ? warningWithoutStack$1( - false, + { + if (Component) { + if (Component.childContextTypes) { + error( "%s(...): childContextTypes cannot be defined on a function component.", Component.displayName || Component.name || "Component" - ) - : void 0; - } + ); + } + } - if (workInProgress.ref !== null) { - var info = ""; - var ownerName = getCurrentFiberOwnerNameInDevOrNull(); + if (workInProgress.ref !== null) { + var info = ""; + var ownerName = getCurrentFiberOwnerNameInDevOrNull(); - if (ownerName) { - info += "\n\nCheck the render method of `" + ownerName + "`."; - } + if (ownerName) { + info += "\n\nCheck the render method of `" + ownerName + "`."; + } - var warningKey = ownerName || workInProgress._debugID || ""; - var debugSource = workInProgress._debugSource; + var warningKey = ownerName || workInProgress._debugID || ""; + var debugSource = workInProgress._debugSource; - if (debugSource) { - warningKey = debugSource.fileName + ":" + debugSource.lineNumber; - } + if (debugSource) { + warningKey = debugSource.fileName + ":" + debugSource.lineNumber; + } - if (!didWarnAboutFunctionRefs[warningKey]) { - didWarnAboutFunctionRefs[warningKey] = true; - warning$1( - false, - "Function components cannot be given refs. " + - "Attempts to access this ref will fail. " + - "Did you mean to use React.forwardRef()?%s", - info - ); + 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 + ); + } } - } - if ( - warnAboutDefaultPropsOnFunctionComponents && - Component.defaultProps !== undefined - ) { - var componentName = getComponentName(Component) || "Unknown"; - - if (!didWarnAboutDefaultPropsOnFunctionComponent[componentName]) { - warningWithoutStack$1( - false, - "%s: Support for defaultProps will be removed from function components " + - "in a future major release. Use JavaScript default parameters instead.", - componentName - ); - didWarnAboutDefaultPropsOnFunctionComponent[componentName] = true; + if ( + warnAboutDefaultPropsOnFunctionComponents && + Component.defaultProps !== undefined + ) { + var componentName = getComponentName(Component) || "Unknown"; + + if (!didWarnAboutDefaultPropsOnFunctionComponent[componentName]) { + error( + "%s: Support for defaultProps will be removed from function components " + + "in a future major release. Use JavaScript default parameters instead.", + componentName + ); + + didWarnAboutDefaultPropsOnFunctionComponent[componentName] = true; + } } - } - if (typeof Component.getDerivedStateFromProps === "function") { - var _componentName2 = getComponentName(Component) || "Unknown"; + if (typeof Component.getDerivedStateFromProps === "function") { + var _componentName2 = getComponentName(Component) || "Unknown"; - if (!didWarnAboutGetDerivedStateOnFunctionComponent[_componentName2]) { - warningWithoutStack$1( - false, - "%s: Function components do not support getDerivedStateFromProps.", - _componentName2 - ); - didWarnAboutGetDerivedStateOnFunctionComponent[_componentName2] = true; + if (!didWarnAboutGetDerivedStateOnFunctionComponent[_componentName2]) { + error( + "%s: Function components do not support getDerivedStateFromProps.", + _componentName2 + ); + + didWarnAboutGetDerivedStateOnFunctionComponent[_componentName2] = true; + } } - } - if ( - typeof Component.contextType === "object" && - Component.contextType !== null - ) { - var _componentName3 = getComponentName(Component) || "Unknown"; + if ( + typeof Component.contextType === "object" && + Component.contextType !== null + ) { + var _componentName3 = getComponentName(Component) || "Unknown"; - if (!didWarnAboutContextTypeOnFunctionComponent[_componentName3]) { - warningWithoutStack$1( - false, - "%s: Function components do not support contextType.", - _componentName3 - ); - didWarnAboutContextTypeOnFunctionComponent[_componentName3] = true; + if (!didWarnAboutContextTypeOnFunctionComponent[_componentName3]) { + error( + "%s: Function components do not support contextType.", + _componentName3 + ); + + didWarnAboutContextTypeOnFunctionComponent[_componentName3] = true; + } } } } @@ -14547,8 +13927,8 @@ function updateSuspenseComponent( if ("maxDuration" in nextProps) { if (!didWarnAboutMaxDuration) { didWarnAboutMaxDuration = true; - warning$1( - false, + + error( "maxDuration has been removed from React. " + "Remove the maxDuration prop." ); @@ -14920,7 +14300,7 @@ function updateSuspenseComponent( workInProgress.child = _primaryChildFragment3; return _fallbackChildFragment3; } else { - // Still haven't timed out. Continue rendering the children, like we + // Still haven't timed out. Continue rendering the children, like we // normally do. workInProgress.memoizedState = null; var _nextPrimaryChildren2 = nextProps.children; @@ -14966,8 +14346,7 @@ function mountDehydratedSuspenseComponent( // Instead, we'll leave the content in place and try to hydrate it later. if ((workInProgress.mode & BlockingMode) === NoMode) { { - warning$1( - false, + error( "Cannot hydrate Suspense in legacy mode. Switch from " + "ReactDOM.hydrate(element, container) to " + "ReactDOM.createBlockingRoot(container, { hydrate: true })" + @@ -15227,40 +14606,39 @@ function validateRevealOrder(revealOrder) { case "together": case "forwards": case "backwards": { - warning$1( - false, + error( '"%s" is not a valid value for revealOrder on . ' + 'Use lowercase "%s" instead.', revealOrder, revealOrder.toLowerCase() ); + break; } case "forward": case "backward": { - warning$1( - false, + 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: - warning$1( - false, + error( '"%s" is not a supported revealOrder on . ' + 'Did you mean "together", "forwards" or "backwards"?', revealOrder ); + break; } } else { - warning$1( - false, + error( "%s is not a supported value for revealOrder on . " + 'Did you mean "together", "forwards" or "backwards"?', revealOrder @@ -15275,16 +14653,16 @@ function validateTailOptions(tailMode, revealOrder) { if (tailMode !== undefined && !didWarnAboutTailOptions[tailMode]) { if (tailMode !== "collapsed" && tailMode !== "hidden") { didWarnAboutTailOptions[tailMode] = true; - warning$1( - false, + + 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; - warning$1( - false, + + error( ' is only valid if revealOrder is ' + '"forwards" or "backwards". ' + 'Did you mean to specify revealOrder="forwards"?', @@ -15302,8 +14680,8 @@ function validateSuspenseListNestedChild(childSlot, index) { if (isArray || isIterable) { var type = isArray ? "array" : "iterable"; - warning$1( - false, + + error( "A nested %s was passed to row #%s in . Wrap it in " + "an additional SuspenseList to configure its revealOrder: " + " ... " + @@ -15313,6 +14691,7 @@ function validateSuspenseListNestedChild(childSlot, index) { index, type ); + return false; } } @@ -15353,8 +14732,7 @@ function validateSuspenseListChildren(children, revealOrder) { } } } else { - warning$1( - false, + 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?", @@ -15380,6 +14758,7 @@ function initSuspenseListRenderState( workInProgress.memoizedState = { isBackwards: isBackwards, rendering: null, + renderingStartTime: 0, last: lastContentRow, tail: tail, tailExpiration: 0, @@ -15390,6 +14769,7 @@ function initSuspenseListRenderState( // 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.tailExpiration = 0; @@ -15662,8 +15042,8 @@ function updateContextConsumer( if (context !== context.Consumer) { if (!hasWarnedAboutUsingContextAsConsumer) { hasWarnedAboutUsingContextAsConsumer = true; - warning$1( - false, + + error( "Rendering directly is not supported and will be removed in " + "a future major release. Did you mean to render instead?" ); @@ -15678,15 +15058,14 @@ function updateContextConsumer( var render = newProps.children; { - !(typeof render === "function") - ? warningWithoutStack$1( - false, - "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." - ) - : void 0; + 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." + ); + } } prepareToReadContext(workInProgress, renderExpirationTime); @@ -16294,6 +15673,22 @@ function beginWork$1(current$$1, workInProgress, renderExpirationTime) { break; } + + case Chunk: { + if (enableChunksAPI) { + var chunk = workInProgress.type; + var props = workInProgress.pendingProps; + return updateChunk( + current$$1, + workInProgress, + chunk, + props, + renderExpirationTime + ); + } + + break; + } } { @@ -16978,6 +16373,8 @@ if (supportsMutation) { // This lets the parents know that at least one of their children has changed. markUpdate(workInProgress); + } else { + workInProgress.stateNode = current.stateNode; } }; } else { @@ -17076,14 +16473,16 @@ function completeWork(current, workInProgress, renderExpirationTime) { switch (workInProgress.tag) { case IndeterminateComponent: - break; - case LazyComponent: - break; - case SimpleMemoComponent: case FunctionComponent: - break; + case ForwardRef: + case Fragment: + case Mode: + case Profiler: + case ContextConsumer: + case MemoComponent: + return null; case ClassComponent: { var Component = workInProgress.type; @@ -17092,7 +16491,7 @@ function completeWork(current, workInProgress, renderExpirationTime) { popContext(workInProgress); } - break; + return null; } case HostRoot: { @@ -17118,7 +16517,7 @@ function completeWork(current, workInProgress, renderExpirationTime) { } updateHostContainer(workInProgress); - break; + return null; } case HostComponent: { @@ -17135,9 +16534,9 @@ function completeWork(current, workInProgress, renderExpirationTime) { rootContainerInstance ); - if (enableFlareAPI) { - var prevListeners = current.memoizedProps.listeners; - var nextListeners = newProps.listeners; + if (enableDeprecatedFlareAPI) { + var prevListeners = current.memoizedProps.DEPRECATED_flareListeners; + var nextListeners = newProps.DEPRECATED_flareListeners; if (prevListeners !== nextListeners) { markUpdate(workInProgress); @@ -17155,12 +16554,12 @@ function completeWork(current, workInProgress, renderExpirationTime) { ); } // This can happen when we abort work. - break; + return null; } 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 we want to add then top->down or + // or completeWork depending on whether we want to add them top->down or // bottom->up. Top->down is faster in IE11. var _wasHydrated = popHydrationState(workInProgress); @@ -17175,16 +16574,16 @@ function completeWork(current, workInProgress, renderExpirationTime) { currentHostContext ) ) { - // If changes to the hydrated node needs to be applied at the + // If changes to the hydrated node need to be applied at the // commit-phase we mark this as such. markUpdate(workInProgress); } - if (enableFlareAPI) { - var listeners = newProps.listeners; + if (enableDeprecatedFlareAPI) { + var listeners = newProps.DEPRECATED_flareListeners; if (listeners != null) { - updateEventListeners( + updateDeprecatedEventListeners( listeners, workInProgress, rootContainerInstance @@ -17203,11 +16602,11 @@ function completeWork(current, workInProgress, renderExpirationTime) { workInProgress.stateNode = instance; - if (enableFlareAPI) { - var _listeners = newProps.listeners; + if (enableDeprecatedFlareAPI) { + var _listeners = newProps.DEPRECATED_flareListeners; if (_listeners != null) { - updateEventListeners( + updateDeprecatedEventListeners( _listeners, workInProgress, rootContainerInstance @@ -17236,7 +16635,7 @@ function completeWork(current, workInProgress, renderExpirationTime) { } } - break; + return null; } case HostText: { @@ -17276,12 +16675,9 @@ function completeWork(current, workInProgress, renderExpirationTime) { } } - break; + return null; } - case ForwardRef: - break; - case SuspenseComponent: { popSuspenseContext(workInProgress); var nextState = workInProgress.memoizedState; @@ -17307,15 +16703,14 @@ function completeWork(current, workInProgress, renderExpirationTime) { } else { // We should never have been in a hydration state if we didn't have a current. // However, in some of those paths, we might have reentered a hydration state - // and then we might be inside a hydration state. In that case, we'll need to - // exit out of it. + // and then we might be inside a hydration state. In that case, we'll need to exit out of it. resetHydrationState(); if ((workInProgress.effectTag & DidCapture) === NoEffect) { // This boundary did not suspend so it's now hydrated and unsuspended. workInProgress.memoizedState = null; } // If nothing suspended, we need to schedule an effect to mark this boundary - // as having hydrated so events know that they're free be invoked. + // as having hydrated so events know that they're free to be invoked. // It's also a signal to replay events and the suspense callback. // If something suspended, schedule an effect to attach retry listeners. // So we might as well always mark this. @@ -17408,7 +16803,7 @@ function completeWork(current, workInProgress, renderExpirationTime) { // 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 proimse. This flag is also used to hide the + // retry listener to the promise. This flag is also used to hide the // primary children. workInProgress.effectTag |= Update; } @@ -17418,9 +16813,9 @@ function completeWork(current, workInProgress, renderExpirationTime) { // 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 proimse. This flag is also used to hide the + // 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 the + // *unhide* children that were previously hidden, so check if this // is currently timed out, too. workInProgress.effectTag |= Update; } @@ -17435,33 +16830,18 @@ function completeWork(current, workInProgress, renderExpirationTime) { workInProgress.effectTag |= Update; } - break; + return null; } - case Fragment: - break; - - case Mode: - break; - - case Profiler: - break; - case HostPortal: popHostContainer(workInProgress); updateHostContainer(workInProgress); - break; + return null; case ContextProvider: // Pop provider fiber popProvider(workInProgress); - break; - - case ContextConsumer: - break; - - case MemoComponent: - break; + return null; case IncompleteClassComponent: { // Same as class component case. I put it down here so that the tags are @@ -17472,7 +16852,7 @@ function completeWork(current, workInProgress, renderExpirationTime) { popContext(workInProgress); } - break; + return null; } case SuspenseListComponent: { @@ -17480,9 +16860,9 @@ function completeWork(current, workInProgress, renderExpirationTime) { var renderState = workInProgress.memoizedState; if (renderState === null) { - // We're running in the default, "independent" mode. We don't do anything - // in this mode. - break; + // We're running in the default, "independent" mode. + // We don't do anything in this mode. + return null; } var didSuspendAlready = @@ -17598,7 +16978,10 @@ function completeWork(current, workInProgress, renderExpirationTime) { return null; } } else if ( - now() > renderState.tailExpiration && + // The time it took to render last row is greater than time until + // the expiration. + now() * 2 - renderState.renderingStartTime > + renderState.tailExpiration && renderExpirationTime > Never ) { // We have now passed our CPU deadline and we'll just give up further @@ -17648,13 +17031,19 @@ function completeWork(current, workInProgress, renderExpirationTime) { // Heuristic for how long we're willing to spend rendering rows // until we just give up and show what we have so far. var TAIL_EXPIRATION_TIMEOUT_MS = 500; - renderState.tailExpiration = now() + TAIL_EXPIRATION_TIMEOUT_MS; + renderState.tailExpiration = now() + TAIL_EXPIRATION_TIMEOUT_MS; // TODO: This is meant to mimic the train model or JND but this + // is a per component value. It should really be since the start + // of the total render or last commit. Consider using something like + // globalMostRecentFallbackTime. That doesn't account for being + // suspended for part of the time or when it's a new render. + // It should probably use a global start time value instead. } // Pop a row. var next = renderState.tail; renderState.rendering = next; renderState.tail = next.sibling; renderState.lastEffect = workInProgress.lastEffect; + 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. @@ -17675,7 +17064,7 @@ function completeWork(current, workInProgress, renderExpirationTime) { return next; } - break; + return null; } case FundamentalComponent: { @@ -17730,6 +17119,8 @@ function completeWork(current, workInProgress, renderExpirationTime) { markUpdate(workInProgress); } } + + return null; } break; @@ -17746,13 +17137,13 @@ function completeWork(current, workInProgress, renderExpirationTime) { workInProgress.stateNode = scopeInstance; scopeInstance.methods = createScopeMethods(_type3, scopeInstance); - if (enableFlareAPI) { - var _listeners2 = newProps.listeners; + if (enableDeprecatedFlareAPI) { + var _listeners2 = newProps.DEPRECATED_flareListeners; if (_listeners2 != null) { var _rootContainerInstance2 = getRootHostContainer(); - updateEventListeners( + updateDeprecatedEventListeners( _listeners2, workInProgress, _rootContainerInstance2 @@ -17765,9 +17156,10 @@ function completeWork(current, workInProgress, renderExpirationTime) { markUpdate(workInProgress); } } else { - if (enableFlareAPI) { - var _prevListeners = current.memoizedProps.listeners; - var _nextListeners = newProps.listeners; + if (enableDeprecatedFlareAPI) { + var _prevListeners = + current.memoizedProps.DEPRECATED_flareListeners; + var _nextListeners = newProps.DEPRECATED_flareListeners; if ( _prevListeners !== _nextListeners || @@ -17785,21 +17177,28 @@ function completeWork(current, workInProgress, renderExpirationTime) { markRef$1(workInProgress); } } + + return null; } break; } - default: { - throw Error( - "Unknown unit of work tag (" + - workInProgress.tag + - "). This error is likely caused by a bug in React. Please file an issue." - ); - } + case Chunk: + if (enableChunksAPI) { + return null; + } + + break; } - 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." + ); + } } function unwindWork(workInProgress, renderExpirationTime) { @@ -17992,7 +17391,8 @@ function logCapturedError(capturedError) { // However, the browser would have silenced the original error // so we'll print it first, and then print the stack addendum. - console.error(error); // For a more detailed description of this block, see: + console["error"](error); // Don't transform to our wrapper + // For a more detailed description of this block, see: // https://github.com/facebook/react/pull/13384 } @@ -18029,7 +17429,7 @@ function logCapturedError(capturedError) { // has already printed it. Even if the application swallows the error, it is still // displayed by the browser thanks to the DEV-only fake event trick in ReactErrorUtils. - console.error(combinedMessage); + console["error"](combinedMessage); // Don't transform to our wrapper } } @@ -18127,8 +17527,8 @@ function safelyCallDestroy(current$$1, destroy) { invokeGuardedCallback(null, destroy, null); if (hasCaughtError()) { - var error = clearCaughtError(); - captureCommitPhaseError(current$$1, error); + var error$$1 = clearCaughtError(); + captureCommitPhaseError(current$$1, error$$1); } } } @@ -18137,7 +17537,8 @@ function commitBeforeMutationLifeCycles(current$$1, finishedWork) { switch (finishedWork.tag) { case FunctionComponent: case ForwardRef: - case SimpleMemoComponent: { + case SimpleMemoComponent: + case Chunk: { commitHookEffectList(UnmountSnapshot, NoEffect$1, finishedWork); return; } @@ -18157,28 +17558,27 @@ function commitBeforeMutationLifeCycles(current$$1, finishedWork) { finishedWork.type === finishedWork.elementType && !didWarnAboutReassigningProps ) { - !(instance.props === finishedWork.memoizedProps) - ? warning$1( - false, - "Expected %s props to match memoized props before " + - "getSnapshotBeforeUpdate. " + - "This might either be because of a bug in React, or because " + - "a component reassigns its own `this.props`. " + - "Please file an issue.", - getComponentName(finishedWork.type) || "instance" - ) - : void 0; - !(instance.state === finishedWork.memoizedState) - ? warning$1( - false, - "Expected %s state to match memoized state before " + - "getSnapshotBeforeUpdate. " + - "This might either be because of a bug in React, or because " + - "a component reassigns its own `this.props`. " + - "Please file an issue.", - getComponentName(finishedWork.type) || "instance" - ) - : void 0; + if (instance.props !== finishedWork.memoizedProps) { + error( + "Expected %s props to match memoized props before " + + "getSnapshotBeforeUpdate. " + + "This might either be because of a bug in React, or because " + + "a component reassigns its own `this.props`. " + + "Please file an issue.", + getComponentName(finishedWork.type) || "instance" + ); + } + + if (instance.state !== finishedWork.memoizedState) { + error( + "Expected %s state to match memoized state before " + + "getSnapshotBeforeUpdate. " + + "This might either be because of a bug in React, or because " + + "a component reassigns its own `this.props`. " + + "Please file an issue.", + getComponentName(finishedWork.type) || "instance" + ); + } } } @@ -18194,8 +17594,8 @@ function commitBeforeMutationLifeCycles(current$$1, finishedWork) { if (snapshot === undefined && !didWarnSet.has(finishedWork.type)) { didWarnSet.add(finishedWork.type); - warningWithoutStack$1( - false, + + error( "%s.getSnapshotBeforeUpdate(): A snapshot value (or null) " + "must be returned. You have returned undefined.", getComponentName(finishedWork.type) @@ -18218,14 +17618,12 @@ function commitBeforeMutationLifeCycles(current$$1, finishedWork) { case IncompleteClassComponent: // Nothing to do for these component types return; + } - 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 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." + ); } } @@ -18281,8 +17679,7 @@ function commitHookEffectList(unmountTag, mountTag, finishedWork) { addendum = " You returned: " + _destroy; } - warningWithoutStack$1( - false, + error( "An effect function must not return anything besides a function, " + "which is used for clean-up.%s%s", addendum, @@ -18302,7 +17699,8 @@ function commitPassiveHookEffects(finishedWork) { switch (finishedWork.tag) { case FunctionComponent: case ForwardRef: - case SimpleMemoComponent: { + case SimpleMemoComponent: + case Chunk: { commitHookEffectList(UnmountPassive, NoEffect$1, finishedWork); commitHookEffectList(NoEffect$1, MountPassive, finishedWork); break; @@ -18323,9 +17721,10 @@ function commitLifeCycles( switch (finishedWork.tag) { case FunctionComponent: case ForwardRef: - case SimpleMemoComponent: { + case SimpleMemoComponent: + case Chunk: { commitHookEffectList(UnmountLayout, MountLayout, finishedWork); - break; + return; } case ClassComponent: { @@ -18342,28 +17741,27 @@ function commitLifeCycles( finishedWork.type === finishedWork.elementType && !didWarnAboutReassigningProps ) { - !(instance.props === finishedWork.memoizedProps) - ? warning$1( - false, - "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.", - getComponentName(finishedWork.type) || "instance" - ) - : void 0; - !(instance.state === finishedWork.memoizedState) - ? warning$1( - false, - "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.props`. " + - "Please file an issue.", - getComponentName(finishedWork.type) || "instance" - ) - : void 0; + 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.", + getComponentName(finishedWork.type) || "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.props`. " + + "Please file an issue.", + getComponentName(finishedWork.type) || "instance" + ); + } } } @@ -18387,28 +17785,27 @@ function commitLifeCycles( finishedWork.type === finishedWork.elementType && !didWarnAboutReassigningProps ) { - !(instance.props === finishedWork.memoizedProps) - ? warning$1( - false, - "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.", - getComponentName(finishedWork.type) || "instance" - ) - : void 0; - !(instance.state === finishedWork.memoizedState) - ? warning$1( - false, - "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.props`. " + - "Please file an issue.", - getComponentName(finishedWork.type) || "instance" - ) - : void 0; + 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.", + getComponentName(finishedWork.type) || "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.props`. " + + "Please file an issue.", + getComponentName(finishedWork.type) || "instance" + ); + } } } @@ -18429,28 +17826,27 @@ function commitLifeCycles( finishedWork.type === finishedWork.elementType && !didWarnAboutReassigningProps ) { - !(instance.props === finishedWork.memoizedProps) - ? warning$1( - false, - "Expected %s props to match memoized props before " + - "processing the update queue. " + - "This might either be because of a bug in React, or because " + - "a component reassigns its own `this.props`. " + - "Please file an issue.", - getComponentName(finishedWork.type) || "instance" - ) - : void 0; - !(instance.state === finishedWork.memoizedState) - ? warning$1( - false, - "Expected %s state to match memoized state before " + - "processing the update queue. " + - "This might either be because of a bug in React, or because " + - "a component reassigns its own `this.props`. " + - "Please file an issue.", - getComponentName(finishedWork.type) || "instance" - ) - : void 0; + if (instance.props !== finishedWork.memoizedProps) { + error( + "Expected %s props to match memoized props before " + + "processing the update queue. " + + "This might either be because of a bug in React, or because " + + "a component reassigns its own `this.props`. " + + "Please file an issue.", + getComponentName(finishedWork.type) || "instance" + ); + } + + if (instance.state !== finishedWork.memoizedState) { + error( + "Expected %s state to match memoized state before " + + "processing the update queue. " + + "This might either be because of a bug in React, or because " + + "a component reassigns its own `this.props`. " + + "Please file an issue.", + getComponentName(finishedWork.type) || "instance" + ); + } } } // We could update instance props and state here, // but instead we rely on them being set during last render. @@ -18562,14 +17958,12 @@ function commitLifeCycles( case FundamentalComponent: case ScopeComponent: return; + } - 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 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." + ); } } @@ -18656,8 +18050,7 @@ function commitAttachRef(finishedWork) { } else { { if (!ref.hasOwnProperty("current")) { - warningWithoutStack$1( - false, + error( "Unexpected ref object provided for %s. " + "Use either a ref-setter function or React.createRef().%s", getComponentName(finishedWork.type), @@ -18692,7 +18085,8 @@ function commitUnmount(finishedRoot, current$$1, renderPriorityLevel) { case FunctionComponent: case ForwardRef: case MemoComponent: - case SimpleMemoComponent: { + case SimpleMemoComponent: + case Chunk: { var updateQueue = current$$1.updateQueue; if (updateQueue !== null) { @@ -18716,7 +18110,7 @@ function commitUnmount(finishedRoot, current$$1, renderPriorityLevel) { renderPriorityLevel > NormalPriority ? NormalPriority : renderPriorityLevel; - runWithPriority$1(priorityLevel, function() { + runWithPriority(priorityLevel, function() { var effect = firstEffect; do { @@ -18732,7 +18126,7 @@ function commitUnmount(finishedRoot, current$$1, renderPriorityLevel) { } } - break; + return; } case ClassComponent: { @@ -18747,27 +18141,9 @@ function commitUnmount(finishedRoot, current$$1, renderPriorityLevel) { } case HostComponent: { - if (enableFlareAPI) { - var dependencies = current$$1.dependencies; - - if (dependencies !== null) { - var respondersMap = dependencies.responders; - - if (respondersMap !== null) { - var responderInstances = Array.from(respondersMap.values()); - - for ( - var i = 0, length = responderInstances.length; - i < length; - i++ - ) { - var responderInstance = responderInstances[i]; - unmountResponderInstance(responderInstance); - } - - dependencies.responders = null; - } - } + if (enableDeprecatedFlareAPI) { + unmountDeprecatedResponderListeners(current$$1); + beforeRemoveInstance(current$$1.stateNode); } safelyDetachRef(current$$1); @@ -18817,9 +18193,15 @@ function commitUnmount(finishedRoot, current$$1, renderPriorityLevel) { } case ScopeComponent: { + if (enableDeprecatedFlareAPI) { + unmountDeprecatedResponderListeners(current$$1); + } + if (enableScopeAPI) { safelyDetachRef(current$$1); } + + return; } } } @@ -18880,6 +18262,7 @@ function detachFiber(current$$1) { current$$1.lastEffect = null; current$$1.pendingProps = null; current$$1.memoizedProps = null; + current$$1.stateNode = null; if (alternate !== null) { detachFiber(alternate); @@ -18916,14 +18299,12 @@ function commitContainer(finishedWork) { pendingChildren = portalOrRoot.pendingChildren; return; } + } - 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 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." + ); } } @@ -19259,7 +18640,8 @@ function commitWork(current$$1, finishedWork) { case FunctionComponent: case ForwardRef: case MemoComponent: - case SimpleMemoComponent: { + case SimpleMemoComponent: + case Chunk: { // Note: We currently never use MountMutation, but useLayout uses // UnmountMutation. commitHookEffectList(UnmountMutation, MountMutation, finishedWork); @@ -19304,7 +18686,8 @@ function commitWork(current$$1, finishedWork) { case FunctionComponent: case ForwardRef: case MemoComponent: - case SimpleMemoComponent: { + case SimpleMemoComponent: + case Chunk: { // Note: We currently never use MountMutation, but useLayout uses // UnmountMutation. commitHookEffectList(UnmountMutation, MountMutation, finishedWork); @@ -19342,12 +18725,12 @@ function commitWork(current$$1, finishedWork) { ); } - if (enableFlareAPI) { - var prevListeners = oldProps.listeners; - var nextListeners = newProps.listeners; + if (enableDeprecatedFlareAPI) { + var prevListeners = oldProps.DEPRECATED_flareListeners; + var nextListeners = newProps.DEPRECATED_flareListeners; if (prevListeners !== nextListeners) { - updateEventListeners(nextListeners, finishedWork, null); + updateDeprecatedEventListeners(nextListeners, finishedWork, null); } } } @@ -19409,9 +18792,10 @@ function commitWork(current$$1, finishedWork) { if (enableFundamentalAPI) { var fundamentalInstance = finishedWork.stateNode; updateFundamentalComponent(fundamentalInstance); + return; } - return; + break; } case ScopeComponent: { @@ -19419,31 +18803,31 @@ function commitWork(current$$1, finishedWork) { var scopeInstance = finishedWork.stateNode; scopeInstance.fiber = finishedWork; - if (enableFlareAPI) { + if (enableDeprecatedFlareAPI) { var _newProps = finishedWork.memoizedProps; var _oldProps = current$$1 !== null ? current$$1.memoizedProps : _newProps; - var _prevListeners = _oldProps.listeners; - var _nextListeners = _newProps.listeners; + var _prevListeners = _oldProps.DEPRECATED_flareListeners; + var _nextListeners = _newProps.DEPRECATED_flareListeners; - if (_prevListeners !== _nextListeners) { - updateEventListeners(_nextListeners, finishedWork, null); + if (_prevListeners !== _nextListeners || current$$1 === null) { + updateDeprecatedEventListeners(_nextListeners, finishedWork, null); } } + + return; } - return; + 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 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." + ); } } @@ -19475,7 +18859,7 @@ function commitSuspenseComponent(finishedWork) { } } else { if (suspenseCallback !== undefined) { - warning$1(false, "Unexpected type for suspenseCallback."); + error("Unexpected type for suspenseCallback."); } } } @@ -19568,10 +18952,10 @@ function createRootErrorUpdate(fiber, errorInfo, expirationTime) { update.payload = { element: null }; - var error = errorInfo.value; + var error$$1 = errorInfo.value; update.callback = function() { - onUncaughtError(error); + onUncaughtError(error$$1); logError(fiber, errorInfo); }; @@ -19584,11 +18968,11 @@ function createClassErrorUpdate(fiber, errorInfo, expirationTime) { var getDerivedStateFromError = fiber.type.getDerivedStateFromError; if (typeof getDerivedStateFromError === "function") { - var error = errorInfo.value; + var error$$1 = errorInfo.value; update.payload = function() { logError(fiber, errorInfo); - return getDerivedStateFromError(error); + return getDerivedStateFromError(error$$1); }; } @@ -19611,9 +18995,9 @@ function createClassErrorUpdate(fiber, errorInfo, expirationTime) { logError(fiber, errorInfo); } - var error = errorInfo.value; + var error$$1 = errorInfo.value; var stack = errorInfo.stack; - this.componentDidCatch(error, { + this.componentDidCatch(error$$1, { componentStack: stack !== null ? stack : "" }); @@ -19622,14 +19006,13 @@ function createClassErrorUpdate(fiber, errorInfo, expirationTime) { // If componentDidCatch is the only error boundary method defined, // then it needs to call setState to recover from errors. // If no state update is scheduled then the boundary will swallow the error. - !(fiber.expirationTime === Sync) - ? warningWithoutStack$1( - false, - "%s: Error boundaries should implement getDerivedStateFromError(). " + - "In that method, return a state update to display an error message or fallback UI.", - getComponentName(fiber.type) || "Unknown" - ) - : void 0; + if (fiber.expirationTime !== Sync) { + error( + "%s: Error boundaries should implement getDerivedStateFromError(). " + + "In that method, return a state update to display an error message or fallback UI.", + getComponentName(fiber.type) || "Unknown" + ); + } } } }; @@ -19694,6 +19077,20 @@ function throwException( ) { // This is a thenable. var thenable = value; + + if ((sourceFiber.mode & BlockingMode) === NoMode) { + // Reset the memoizedState to what it was before we attempted + // to render it. + var currentSource = sourceFiber.alternate; + + if (currentSource) { + sourceFiber.memoizedState = currentSource.memoizedState; + sourceFiber.expirationTime = currentSource.expirationTime; + } else { + sourceFiber.memoizedState = null; + } + } + checkForWrongSuspensePriorityInDEV(sourceFiber); var hasInvisibleParentBoundary = hasSuspenseContext( suspenseStackCursor.current, @@ -20018,7 +19415,7 @@ function computeExpirationForFiber(currentTime, fiber, suspenseConfig) { expirationTime = Sync; break; - case UserBlockingPriority$1: + case UserBlockingPriority: // TODO: Rename this to computeUserBlockingExpiration expirationTime = computeInteractiveExpiration(currentTime); break; @@ -20100,7 +19497,7 @@ function scheduleUpdateOnFiber(fiber, expirationTime) { if ( (executionContext & DiscreteEventContext) !== NoContext && // Only updates at user-blocking priority or greater are considered // discrete, even inside a discrete event. - (priorityLevel === UserBlockingPriority$1 || + (priorityLevel === UserBlockingPriority || priorityLevel === ImmediatePriority) ) { // This is the result of a discrete event. Track the lowest priority @@ -20219,9 +19616,21 @@ function getNextRootExpirationTimeToWorkOn(root) { var lastPingedTime = root.lastPingedTime; var nextKnownPendingLevel = root.nextKnownPendingLevel; - return lastPingedTime > nextKnownPendingLevel - ? lastPingedTime - : nextKnownPendingLevel; + var nextLevel = + lastPingedTime > nextKnownPendingLevel + ? lastPingedTime + : nextKnownPendingLevel; + + if ( + enableTrainModelFix && + nextLevel <= Idle && + firstPendingTime !== nextLevel + ) { + // Don't work on Idle/Never priority unless everything else is committed. + return NoWork; + } + + return nextLevel; } // Use this function to schedule a task for a root. There's only one task per // root; if a task was already scheduled, we'll check to make sure the // expiration time of the existing task is the same as the expiration time of @@ -20669,80 +20078,70 @@ function performSyncWorkOnRoot(root) { var lastExpiredTime = root.lastExpiredTime; var expirationTime = lastExpiredTime !== NoWork ? lastExpiredTime : Sync; - if (root.finishedExpirationTime === expirationTime) { - // There's already a pending commit at this expiration time. - // TODO: This is poorly factored. This case only exists for the - // batch.commit() API. - commitRoot(root); - } else { - if (!((executionContext & (RenderContext | CommitContext)) === NoContext)) { - throw Error("Should not already be working."); - } - - flushPassiveEffects(); // If the root or expiration time have changed, throw out the existing stack - // and prepare a fresh one. Otherwise we'll continue where we left off. - - if ( - root !== workInProgressRoot || - expirationTime !== renderExpirationTime - ) { - prepareFreshStack(root, expirationTime); - startWorkOnPendingInteractions(root, expirationTime); - } // If we have a work-in-progress fiber, it means there's still work to do - // in this root. + if (!((executionContext & (RenderContext | CommitContext)) === NoContext)) { + throw Error("Should not already be working."); + } - if (workInProgress !== null) { - var prevExecutionContext = executionContext; - executionContext |= RenderContext; - var prevDispatcher = pushDispatcher(root); - var prevInteractions = pushInteractions(root); - startWorkLoopTimer(workInProgress); + flushPassiveEffects(); // If the root or expiration time have changed, throw out the existing stack + // and prepare a fresh one. Otherwise we'll continue where we left off. - do { - try { - workLoopSync(); - break; - } catch (thrownValue) { - handleError(root, thrownValue); - } - } while (true); + if (root !== workInProgressRoot || expirationTime !== renderExpirationTime) { + prepareFreshStack(root, expirationTime); + startWorkOnPendingInteractions(root, expirationTime); + } // If we have a work-in-progress fiber, it means there's still work to do + // in this root. - resetContextDependencies(); - executionContext = prevExecutionContext; - popDispatcher(prevDispatcher); + if (workInProgress !== null) { + var prevExecutionContext = executionContext; + executionContext |= RenderContext; + var prevDispatcher = pushDispatcher(root); + var prevInteractions = pushInteractions(root); + startWorkLoopTimer(workInProgress); - if (enableSchedulerTracing) { - popInteractions(prevInteractions); + do { + try { + workLoopSync(); + break; + } catch (thrownValue) { + handleError(root, thrownValue); } + } while (true); - if (workInProgressRootExitStatus === RootFatalErrored) { - var fatalError = workInProgressRootFatalError; - stopInterruptedWorkLoopTimer(); - prepareFreshStack(root, expirationTime); - markRootSuspendedAtTime(root, expirationTime); - ensureRootIsScheduled(root); - throw fatalError; - } + resetContextDependencies(); + executionContext = prevExecutionContext; + popDispatcher(prevDispatcher); - if (workInProgress !== null) { - // This is a sync render, so we should have finished the whole tree. - { - throw Error( - "Cannot commit an incomplete root. This error is likely caused by a bug in React. Please file an issue." - ); - } - } else { - // We now have a consistent tree. Because this is a sync render, we - // will commit it even if something suspended. - stopFinishedWorkLoopTimer(); - root.finishedWork = root.current.alternate; - root.finishedExpirationTime = expirationTime; - finishSyncRender(root, workInProgressRootExitStatus, expirationTime); - } // Before exiting, make sure there's a callback scheduled for the next - // pending level. + if (enableSchedulerTracing) { + popInteractions(prevInteractions); + } + if (workInProgressRootExitStatus === RootFatalErrored) { + var fatalError = workInProgressRootFatalError; + stopInterruptedWorkLoopTimer(); + prepareFreshStack(root, expirationTime); + markRootSuspendedAtTime(root, expirationTime); ensureRootIsScheduled(root); + throw fatalError; } + + 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." + ); + } + } else { + // We now have a consistent tree. Because this is a sync render, we + // will commit it even if something suspended. + stopFinishedWorkLoopTimer(); + root.finishedWork = root.current.alternate; + root.finishedExpirationTime = expirationTime; + finishSyncRender(root, workInProgressRootExitStatus, expirationTime); + } // Before exiting, make sure there's a callback scheduled for the next + // pending level. + + ensureRootIsScheduled(root); } return null; @@ -20770,12 +20169,13 @@ function flushDiscreteUpdates() { (executionContext & (BatchedContext | RenderContext | CommitContext)) !== NoContext ) { - if (true && (executionContext & RenderContext) !== NoContext) { - warning$1( - false, - "unstable_flushDiscreteUpdates: Cannot flush updates when React is " + - "already rendering." - ); + { + if ((executionContext & RenderContext) !== NoContext) { + error( + "unstable_flushDiscreteUpdates: Cannot flush updates when React is " + + "already rendering." + ); + } } // We're already rendering, so we can't synchronously flush pending work. // This is probably a nested event dispatch triggered by a lifecycle/effect, // like `el.focus()`. Exit. @@ -20790,7 +20190,7 @@ function flushDiscreteUpdates() { } function syncUpdates(fn, a, b, c) { - return runWithPriority$1(ImmediatePriority, fn.bind(null, a, b, c)); + return runWithPriority(ImmediatePriority, fn.bind(null, a, b, c)); } function flushPendingDiscreteUpdates() { @@ -20844,7 +20244,7 @@ function discreteUpdates$1(fn, a, b, c) { try { // Should this - return runWithPriority$1(UserBlockingPriority$1, fn.bind(null, a, b, c)); + return runWithPriority(UserBlockingPriority, fn.bind(null, a, b, c)); } finally { executionContext = prevExecutionContext; @@ -20868,7 +20268,7 @@ function flushSync(fn, a) { executionContext |= BatchedContext; try { - return runWithPriority$1(ImmediatePriority, fn.bind(null, a)); + return runWithPriority(ImmediatePriority, fn.bind(null, a)); } finally { executionContext = prevExecutionContext; // Flush the immediate callbacks that were scheduled during this batch. // Note that this will happen even if batchedUpdates is higher up @@ -21353,7 +20753,7 @@ function resetChildExpirationTime(completedWork) { function commitRoot(root) { var renderPriorityLevel = getCurrentPriorityLevel(); - runWithPriority$1( + runWithPriority( ImmediatePriority, commitRootImpl.bind(null, root, renderPriorityLevel) ); @@ -21361,7 +20761,16 @@ function commitRoot(root) { } function commitRootImpl(root, renderPriorityLevel) { - flushPassiveEffects(); + do { + // `flushPassiveEffects` will call `flushSyncUpdateQueue` at the end, which + // means `flushPassiveEffects` will sometimes result in additional + // passive effects. So we need to keep flushing in a loop until there are + // no more pending effects. + // TODO: Might be better if `flushPassiveEffects` did not automatically + // flush synchronous work at the end, to avoid factoring hazards like this. + flushPassiveEffects(); + } while (rootWithPendingPassiveEffects !== null); + flushRenderPhaseStrictModeWarningsInDEV(); if (!((executionContext & (RenderContext | CommitContext)) === NoContext)) { @@ -21455,8 +20864,8 @@ function commitRootImpl(root, renderPriorityLevel) { throw Error("Should be working on an effect."); } - var error = clearCaughtError(); - captureCommitPhaseError(nextEffect, error); + var error$$1 = clearCaughtError(); + captureCommitPhaseError(nextEffect, error$$1); nextEffect = nextEffect.nextEffect; } } @@ -21792,7 +21201,7 @@ function flushPassiveEffects() { ? NormalPriority : pendingPassiveEffectsRenderPriority; pendingPassiveEffectsRenderPriority = NoPriority; - return runWithPriority$1(priorityLevel, flushPassiveEffectsImpl); + return runWithPriority(priorityLevel, flushPassiveEffectsImpl); } } @@ -21828,8 +21237,8 @@ function flushPassiveEffectsImpl() { throw Error("Should be working on an effect."); } - var error = clearCaughtError(); - captureCommitPhaseError(effect, error); + var error$$1 = clearCaughtError(); + captureCommitPhaseError(effect, error$$1); } resetCurrentFiber(); @@ -21869,17 +21278,17 @@ function markLegacyErrorBoundaryAsFailed(instance) { } } -function prepareToThrowUncaughtError(error) { +function prepareToThrowUncaughtError(error$$1) { if (!hasUncaughtError) { hasUncaughtError = true; - firstUncaughtError = error; + firstUncaughtError = error$$1; } } var onUncaughtError = prepareToThrowUncaughtError; -function captureCommitPhaseErrorOnRoot(rootFiber, sourceFiber, error) { - var errorInfo = createCapturedValue(error, sourceFiber); +function captureCommitPhaseErrorOnRoot(rootFiber, sourceFiber, error$$1) { + var errorInfo = createCapturedValue(error$$1, sourceFiber); var update = createRootErrorUpdate(rootFiber, errorInfo, Sync); enqueueUpdate(rootFiber, update); var root = markUpdateTimeFromFiberToRoot(rootFiber, Sync); @@ -21890,11 +21299,11 @@ function captureCommitPhaseErrorOnRoot(rootFiber, sourceFiber, error) { } } -function captureCommitPhaseError(sourceFiber, error) { +function captureCommitPhaseError(sourceFiber, error$$1) { if (sourceFiber.tag === HostRoot) { // Error was thrown at the root. There is no parent, so the root // itself should capture it. - captureCommitPhaseErrorOnRoot(sourceFiber, sourceFiber, error); + captureCommitPhaseErrorOnRoot(sourceFiber, sourceFiber, error$$1); return; } @@ -21902,7 +21311,7 @@ function captureCommitPhaseError(sourceFiber, error) { while (fiber !== null) { if (fiber.tag === HostRoot) { - captureCommitPhaseErrorOnRoot(fiber, sourceFiber, error); + captureCommitPhaseErrorOnRoot(fiber, sourceFiber, error$$1); return; } else if (fiber.tag === ClassComponent) { var ctor = fiber.type; @@ -21913,7 +21322,7 @@ function captureCommitPhaseError(sourceFiber, error) { (typeof instance.componentDidCatch === "function" && !isAlreadyFailedLegacyErrorBoundary(instance)) ) { - var errorInfo = createCapturedValue(error, sourceFiber); + var errorInfo = createCapturedValue(error$$1, sourceFiber); var update = createClassErrorUpdate( fiber, errorInfo, // TODO: This is always sync @@ -21987,7 +21396,7 @@ function pingSuspendedRoot(root, thenable, suspendedTime) { root.lastPingedTime = suspendedTime; - if (root.finishedExpirationTime === suspendedTime) { + if (!enableTrainModelFix && root.finishedExpirationTime === suspendedTime) { // If there's a pending fallback waiting to commit, throw it away. root.finishedExpirationTime = NoWork; root.finishedWork = null; @@ -22141,8 +21550,8 @@ function checkForNestedUpdates() { { if (nestedPassiveUpdateCount > NESTED_PASSIVE_UPDATE_LIMIT) { nestedPassiveUpdateCount = 0; - warning$1( - false, + + error( "Maximum update depth exceeded. This can happen when a component " + "calls setState inside useEffect, but useEffect either doesn't " + "have a dependency array, or one of the dependencies changes on " + @@ -22197,7 +21606,8 @@ function warnAboutUpdateOnUnmountedFiberInDEV(fiber) { tag !== FunctionComponent && tag !== ForwardRef && tag !== MemoComponent && - tag !== SimpleMemoComponent + tag !== SimpleMemoComponent && + tag !== Chunk ) { // Only warn for user-defined components, not internal ones like Suspense. return; @@ -22216,8 +21626,7 @@ function warnAboutUpdateOnUnmountedFiberInDEV(fiber) { didWarnStateUpdateForUnmountedComponent = new Set([componentName]); } - warningWithoutStack$1( - false, + error( "Can't perform a React state update on an unmounted component. This " + "is a no-op, but it indicates a memory leak in your application. To " + "fix, cancel all subscriptions and asynchronous tasks in %s.%s", @@ -22308,10 +21717,10 @@ function warnAboutInvalidUpdatesOnClassComponentsInDEV(fiber) { return; } - warningWithoutStack$1( - false, + error( "setState(...): Cannot call setState() inside getChildContext()" ); + didWarnAboutUpdateInGetChildContext = true; break; @@ -22320,12 +21729,12 @@ function warnAboutInvalidUpdatesOnClassComponentsInDEV(fiber) { return; } - warningWithoutStack$1( - false, + error( "Cannot update during an existing state transition (such as " + "within `render`). Render methods should be a pure function of " + "props and state." ); + didWarnAboutUpdateInRender = true; break; } @@ -22343,8 +21752,7 @@ function warnIfNotScopedWithMatchingAct(fiber) { IsSomeRendererActing.current === true && IsThisRendererActing.current !== true ) { - warningWithoutStack$1( - false, + 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" + @@ -22370,8 +21778,7 @@ function warnIfNotCurrentlyActingEffectsInDEV(fiber) { IsSomeRendererActing.current === false && IsThisRendererActing.current === false ) { - warningWithoutStack$1( - 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" + @@ -22398,8 +21805,7 @@ function warnIfNotCurrentlyActingUpdatesInDEV(fiber) { IsSomeRendererActing.current === false && IsThisRendererActing.current === false ) { - warningWithoutStack$1( - false, + error( "An update to %s inside a test was not wrapped in act(...).\n\n" + "When testing, code that causes React state updates should be " + "wrapped into act(...):\n\n" + @@ -22433,8 +21839,8 @@ function warnIfUnmockedScheduler(fiber) { ) { if (fiber.mode & BlockingMode || fiber.mode & ConcurrentMode) { didWarnAboutUnmockedScheduler = true; - warningWithoutStack$1( - false, + + 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" + @@ -22443,8 +21849,8 @@ function warnIfUnmockedScheduler(fiber) { ); } else if (warnAboutUnmockedScheduler === true) { didWarnAboutUnmockedScheduler = true; - warningWithoutStack$1( - false, + + error( 'Starting from React v17, the "scheduler" module will need to be mocked ' + "to guarantee consistent behaviour across tests and browsers. " + "For example, with jest: \n" + @@ -22462,7 +21868,7 @@ function checkForWrongSuspensePriorityInDEV(sourceFiber) { if ( (sourceFiber.mode & ConcurrentMode) !== NoEffect && - (currentPriorityLevel === UserBlockingPriority$1 || + (currentPriorityLevel === UserBlockingPriority || currentPriorityLevel === ImmediatePriority) ) { var workInProgressNode = sourceFiber; @@ -22481,13 +21887,13 @@ function checkForWrongSuspensePriorityInDEV(sourceFiber) { var updateQueue = current$$1.updateQueue; if (updateQueue !== null) { - var update = updateQueue.firstUpdate; + var update = updateQueue.baseQueue; while (update !== null) { var priorityLevel = update.priority; if ( - priorityLevel === UserBlockingPriority$1 || + priorityLevel === UserBlockingPriority || priorityLevel === ImmediatePriority ) { if (componentsThatTriggeredHighPriSuspend === null) { @@ -22512,18 +21918,18 @@ function checkForWrongSuspensePriorityInDEV(sourceFiber) { case FunctionComponent: case ForwardRef: case SimpleMemoComponent: - if ( - workInProgressNode.memoizedState !== null && - workInProgressNode.memoizedState.baseUpdate !== null - ) { - var _update = workInProgressNode.memoizedState.baseUpdate; // Loop through the functional component's memoized state to see whether + case Chunk: { + var firstHook = current$$1.memoizedState; // TODO: This just checks the first Hook. Isn't it suppose to check all Hooks? + + if (firstHook !== null && firstHook.baseQueue !== null) { + var _update = firstHook.baseQueue; // Loop through the functional component's memoized state to see whether // the component has triggered any high pri updates while (_update !== null) { var priority = _update.priority; if ( - priority === UserBlockingPriority$1 || + priority === UserBlockingPriority || priority === ImmediatePriority ) { if (componentsThatTriggeredHighPriSuspend === null) { @@ -22539,9 +21945,7 @@ function checkForWrongSuspensePriorityInDEV(sourceFiber) { break; } - if ( - _update.next === workInProgressNode.memoizedState.baseUpdate - ) { + if (_update.next === firstHook.baseQueue) { break; } @@ -22550,6 +21954,7 @@ function checkForWrongSuspensePriorityInDEV(sourceFiber) { } break; + } default: break; @@ -22572,8 +21977,7 @@ function flushSuspensePriorityWarningInDEV() { componentsThatTriggeredHighPriSuspend = null; if (componentNames.length > 0) { - warningWithoutStack$1( - false, + error( "%s triggered a user-blocking update that suspended." + "\n\n" + "The fix is to split the update into multiple parts: a user-blocking " + @@ -22686,10 +22090,10 @@ function startWorkOnPendingInteractions(root, expirationTime) { try { subscriber.onWorkStarted(interactions, threadID); - } catch (error) { + } catch (error$$1) { // If the subscriber throws, rethrow it in a separate task scheduleCallback(ImmediatePriority, function() { - throw error; + throw error$$1; }); } } @@ -22711,10 +22115,10 @@ function finishPendingInteractions(root, committedExpirationTime) { var threadID = computeThreadID(root, committedExpirationTime); subscriber.onWorkStopped(root.memoizedInteractions, threadID); } - } catch (error) { + } catch (error$$1) { // If the subscriber throws, rethrow it in a separate task scheduleCallback(ImmediatePriority, function() { - throw error; + throw error$$1; }); } finally { // Clear completed interactions from the pending Map. @@ -22736,10 +22140,10 @@ function finishPendingInteractions(root, committedExpirationTime) { if (subscriber !== null && interaction.__count === 0) { try { subscriber.onInteractionScheduledWorkCompleted(interaction); - } catch (error) { + } catch (error$$1) { // If the subscriber throws, rethrow it in a separate task scheduleCallback(ImmediatePriority, function() { - throw error; + throw error$$1; }); } } @@ -22749,6 +22153,7 @@ function finishPendingInteractions(root, committedExpirationTime) { } } +var onScheduleFiberRoot = null; var onCommitFiberRoot = null; var onCommitFiberUnmount = null; var hasLoggedError = false; @@ -22770,8 +22175,7 @@ function injectInternals(internals) { if (!hook.supportsFiber) { { - warningWithoutStack$1( - false, + error( "The installed version of React DevTools is too old and will not work " + "with the current version of React. Please update React DevTools. " + "https://fb.me/react-devtools" @@ -22784,6 +22188,23 @@ function injectInternals(internals) { try { var rendererID = hook.inject(internals); // We have successfully injected, so now it is safe to set up hooks. + { + // Only used by Fast Refresh + if (typeof hook.onScheduleFiberRoot === "function") { + onScheduleFiberRoot = function(root, children) { + try { + hook.onScheduleFiberRoot(rendererID, root, children); + } catch (err) { + if (true && !hasLoggedError) { + hasLoggedError = true; + + error("React instrumentation encountered an error: %s", err); + } + } + }; + } + } + onCommitFiberRoot = function(root, expirationTime) { try { var didError = (root.current.effectTag & DidCapture) === DidCapture; @@ -22799,13 +22220,12 @@ function injectInternals(internals) { hook.onCommitFiberRoot(rendererID, root, undefined, didError); } } catch (err) { - if (true && !hasLoggedError) { - hasLoggedError = true; - warningWithoutStack$1( - false, - "React DevTools encountered an error: %s", - err - ); + { + if (!hasLoggedError) { + hasLoggedError = true; + + error("React instrumentation encountered an error: %s", err); + } } } }; @@ -22814,29 +22234,29 @@ function injectInternals(internals) { try { hook.onCommitFiberUnmount(rendererID, fiber); } catch (err) { - if (true && !hasLoggedError) { - hasLoggedError = true; - warningWithoutStack$1( - false, - "React DevTools encountered an error: %s", - err - ); + { + if (!hasLoggedError) { + hasLoggedError = true; + + error("React instrumentation encountered an error: %s", err); + } } } }; } catch (err) { // Catch all errors because it is unsafe to throw during initialization. { - warningWithoutStack$1( - false, - "React DevTools encountered an error: %s.", - err - ); + error("React instrumentation encountered an error: %s.", err); } } // DevTools exists return true; } +function onScheduleRoot(root, children) { + if (typeof onScheduleFiberRoot === "function") { + onScheduleFiberRoot(root, children); + } +} function onCommitRoot(root, expirationTime) { if (typeof onCommitFiberRoot === "function") { onCommitFiberRoot(root, expirationTime); @@ -22984,6 +22404,12 @@ function resolveLazyComponentTag(Component) { if ($$typeof === REACT_MEMO_TYPE) { return MemoComponent; } + + if (enableChunksAPI) { + if ($$typeof === REACT_CHUNK_TYPE) { + return Chunk; + } + } } return IndeterminateComponent; @@ -23264,6 +22690,10 @@ function createFiberFromTypeAndProps( resolvedType = null; break getTag; + case REACT_CHUNK_TYPE: + fiberTag = Chunk; + break getTag; + case REACT_FUNDAMENTAL_TYPE: if (enableFundamentalAPI) { return createFiberFromFundamental( @@ -23389,8 +22819,7 @@ function createFiberFromProfiler(pendingProps, mode, expirationTime, key) { typeof pendingProps.id !== "string" || typeof pendingProps.onRender !== "function" ) { - warningWithoutStack$1( - false, + error( 'Profiler must specify an "id" string and "onRender" function as props' ); } @@ -23552,6 +22981,7 @@ function createFiberRoot(containerInfo, tag, hydrate, hydrationCallbacks) { var uninitializedFiber = createHostRootFiber(tag); root.current = uninitializedFiber; uninitializedFiber.stateNode = root; + initializeUpdateQueue(uninitializedFiber); return root; } function isRootSuspendedAtTime(root, expirationTime) { @@ -23645,15 +23075,6 @@ function markRootExpiredAtTime(root, expirationTime) { } } -// This lets us hook into Fiber to debug what it's doing. -// See https://github.com/facebook/react/pull/8033. -// This is not part of the public API, not even for React DevTools. -// You may only inject a debugTool if you work on React Fiber itself. -var ReactFiberInstrumentation = { - debugTool: null -}; -var ReactFiberInstrumentation_1 = ReactFiberInstrumentation; - var didWarnAboutNestedUpdates; var didWarnAboutFindNodeInStrictMode; @@ -23740,8 +23161,7 @@ function findHostInstanceWithWarning(component, methodName) { didWarnAboutFindNodeInStrictMode[componentName] = true; if (fiber.mode & StrictMode) { - warningWithoutStack$1( - false, + error( "%s is deprecated in StrictMode. " + "%s was passed an instance of %s which is inside StrictMode. " + "Instead, add a ref directly to the element you want to reference. " + @@ -23753,8 +23173,7 @@ function findHostInstanceWithWarning(component, methodName) { getStackByFiberInDevAndProd(hostFiber) ); } else { - warningWithoutStack$1( - false, + error( "%s is deprecated in StrictMode. " + "%s was passed an instance of %s which renders StrictMode children. " + "Instead, add a ref directly to the element you want to reference. " + @@ -23779,6 +23198,10 @@ function createContainer(containerInfo, tag, hydrate, hydrationCallbacks) { return createFiberRoot(containerInfo, tag, hydrate, hydrationCallbacks); } function updateContainer(element, container, parentComponent, callback) { + { + onScheduleRoot(container, element); + } + var current$$1 = container.current; var currentTime = requestCurrentTimeForUpdate(); @@ -23796,19 +23219,6 @@ function updateContainer(element, container, parentComponent, callback) { current$$1, suspenseConfig ); - - { - if (ReactFiberInstrumentation_1.debugTool) { - if (current$$1.alternate === null) { - ReactFiberInstrumentation_1.debugTool.onMountContainer(container); - } else if (element === null) { - ReactFiberInstrumentation_1.debugTool.onUnmountContainer(container); - } else { - ReactFiberInstrumentation_1.debugTool.onUpdateContainer(container); - } - } - } - var context = getContextForSubtree(parentComponent); if (container.context === null) { @@ -23820,8 +23230,8 @@ function updateContainer(element, container, parentComponent, callback) { { if (phase === "render" && current !== null && !didWarnAboutNestedUpdates) { didWarnAboutNestedUpdates = true; - warningWithoutStack$1( - false, + + error( "Render methods should be a pure function of props and state; " + "triggering nested component updates from render is not allowed. " + "If necessary, trigger nested updates in componentDidUpdate.\n\n" + @@ -23840,14 +23250,16 @@ function updateContainer(element, container, parentComponent, callback) { callback = callback === undefined ? null : callback; if (callback !== null) { - !(typeof callback === "function") - ? warningWithoutStack$1( - false, + { + if (typeof callback !== "function") { + error( "render(...): Expected the last optional `callback` argument to be a " + "function. Instead received: %s.", callback - ) - : void 0; + ); + } + } + update.callback = callback; } @@ -24005,7 +23417,7 @@ function createPortal( // TODO: this is special because it gets imported during build. -var ReactVersion = "16.11.0"; +var ReactVersion = "16.12.0-experimental-19f6fe170"; var NativeMethodsMixin = function(findNodeHandle, findHostInstance) { /** @@ -24049,7 +23461,7 @@ var NativeMethodsMixin = function(findNodeHandle, findHostInstance) { try { maybeInstance = findHostInstance(this); - } catch (error) {} // If there is no host component beneath this we should fail silently. + } catch (error$$1) {} // If there is no host component beneath this we should fail silently. // This is not an error; it could mean a class component rendered null. if (maybeInstance == null) { @@ -24095,7 +23507,7 @@ var NativeMethodsMixin = function(findNodeHandle, findHostInstance) { try { maybeInstance = findHostInstance(this); - } catch (error) {} // If there is no host component beneath this we should fail silently. + } catch (error$$1) {} // If there is no host component beneath this we should fail silently. // This is not an error; it could mean a class component rendered null. if (maybeInstance == null) { @@ -24139,7 +23551,7 @@ var NativeMethodsMixin = function(findNodeHandle, findHostInstance) { try { maybeInstance = findHostInstance(this); - } catch (error) {} // If there is no host component beneath this we should fail silently. + } catch (error$$1) {} // If there is no host component beneath this we should fail silently. // This is not an error; it could mean a class component rendered null. if (maybeInstance == null) { @@ -24147,12 +23559,14 @@ var NativeMethodsMixin = function(findNodeHandle, findHostInstance) { } if (maybeInstance.canonical) { - warningWithoutStack$1( - false, - "Warning: measureLayout on components using NativeMethodsMixin " + - "or ReactNative.NativeComponent is not currently supported in Fabric. " + - "measureLayout must be called on a native ref. Consider using forwardRef." - ); + { + error( + "Warning: measureLayout on components using NativeMethodsMixin " + + "or ReactNative.NativeComponent is not currently supported in Fabric. " + + "measureLayout must be called on a native ref. Consider using forwardRef." + ); + } + return; } else { var relativeNode; @@ -24165,10 +23579,12 @@ var NativeMethodsMixin = function(findNodeHandle, findHostInstance) { } if (relativeNode == null) { - warningWithoutStack$1( - false, - "Warning: ref.measureLayout must be called with a node handle or a ref to a native component." - ); + { + error( + "Warning: ref.measureLayout must be called with a node handle or a ref to a native component." + ); + } + return; } @@ -24200,7 +23616,7 @@ var NativeMethodsMixin = function(findNodeHandle, findHostInstance) { try { maybeInstance = findHostInstance(this); - } catch (error) {} // If there is no host component beneath this we should fail silently. + } catch (error$$1) {} // If there is no host component beneath this we should fail silently. // This is not an error; it could mean a class component rendered null. if (maybeInstance == null) { @@ -24208,10 +23624,10 @@ var NativeMethodsMixin = function(findNodeHandle, findHostInstance) { } if (maybeInstance.canonical) { - warningWithoutStack$1( - false, - "Warning: setNativeProps is not currently supported in Fabric" - ); + { + error("Warning: setNativeProps is not currently supported in Fabric"); + } + return; } @@ -24302,7 +23718,13 @@ var NativeMethodsMixin = function(findNodeHandle, findHostInstance) { return NativeMethodsMixin; }; -var ReactNativeComponent$1 = function(findNodeHandle, findHostInstance) { +function _inheritsLoose(subClass, superClass) { + subClass.prototype = Object.create(superClass.prototype); + subClass.prototype.constructor = subClass; + subClass.__proto__ = superClass; +} + +var ReactNativeComponent = function(findNodeHandle, findHostInstance) { /** * Superclass that provides methods to access the underlying native component. * This can be useful when you want to focus a view or measure its dimensions. @@ -24371,7 +23793,7 @@ var ReactNativeComponent$1 = function(findNodeHandle, findHostInstance) { try { maybeInstance = findHostInstance(this); - } catch (error) {} // If there is no host component beneath this we should fail silently. + } catch (error$$1) {} // If there is no host component beneath this we should fail silently. // This is not an error; it could mean a class component rendered null. if (maybeInstance == null) { @@ -24415,7 +23837,7 @@ var ReactNativeComponent$1 = function(findNodeHandle, findHostInstance) { try { maybeInstance = findHostInstance(this); - } catch (error) {} // If there is no host component beneath this we should fail silently. + } catch (error$$1) {} // If there is no host component beneath this we should fail silently. // This is not an error; it could mean a class component rendered null. if (maybeInstance == null) { @@ -24456,7 +23878,7 @@ var ReactNativeComponent$1 = function(findNodeHandle, findHostInstance) { try { maybeInstance = findHostInstance(this); - } catch (error) {} // If there is no host component beneath this we should fail silently. + } catch (error$$1) {} // If there is no host component beneath this we should fail silently. // This is not an error; it could mean a class component rendered null. if (maybeInstance == null) { @@ -24464,12 +23886,14 @@ var ReactNativeComponent$1 = function(findNodeHandle, findHostInstance) { } if (maybeInstance.canonical) { - warningWithoutStack$1( - false, - "Warning: measureLayout on components using NativeMethodsMixin " + - "or ReactNative.NativeComponent is not currently supported in Fabric. " + - "measureLayout must be called on a native ref. Consider using forwardRef." - ); + { + error( + "Warning: measureLayout on components using NativeMethodsMixin " + + "or ReactNative.NativeComponent is not currently supported in Fabric. " + + "measureLayout must be called on a native ref. Consider using forwardRef." + ); + } + return; } else { var relativeNode; @@ -24482,10 +23906,12 @@ var ReactNativeComponent$1 = function(findNodeHandle, findHostInstance) { } if (relativeNode == null) { - warningWithoutStack$1( - false, - "Warning: ref.measureLayout must be called with a node handle or a ref to a native component." - ); + { + error( + "Warning: ref.measureLayout must be called with a node handle or a ref to a native component." + ); + } + return; } @@ -24517,7 +23943,7 @@ var ReactNativeComponent$1 = function(findNodeHandle, findHostInstance) { try { maybeInstance = findHostInstance(this); - } catch (error) {} // If there is no host component beneath this we should fail silently. + } catch (error$$1) {} // If there is no host component beneath this we should fail silently. // This is not an error; it could mean a class component rendered null. if (maybeInstance == null) { @@ -24525,10 +23951,12 @@ var ReactNativeComponent$1 = function(findNodeHandle, findHostInstance) { } if (maybeInstance.canonical) { - warningWithoutStack$1( - false, - "Warning: setNativeProps is not currently supported in Fabric" - ); + { + error( + "Warning: setNativeProps is not currently supported in Fabric" + ); + } + return; } @@ -24672,8 +24100,6 @@ var getInspectorDataForViewTag; }; } -var _nativeFabricUIManage = nativeFabricUIManager; -var fabricDispatchCommand = _nativeFabricUIManage.dispatchCommand; var ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner; function findHostInstance_DEPRECATED(componentOrHandle) { @@ -24681,17 +24107,17 @@ function findHostInstance_DEPRECATED(componentOrHandle) { var owner = ReactCurrentOwner.current; if (owner !== null && owner.stateNode !== null) { - !owner.stateNode._warnedAboutRefsInRender - ? warningWithoutStack$1( - false, - "%s is accessing findNodeHandle inside its render(). " + - "render() should be a pure function of props and state. It should " + - "never access something that requires stale data from the previous " + - "render, such as refs. Move this logic to componentDidMount and " + - "componentDidUpdate instead.", - getComponentName(owner.type) || "A component" - ) - : void 0; + if (!owner.stateNode._warnedAboutRefsInRender) { + error( + "%s is accessing findNodeHandle inside its render(). " + + "render() should be a pure function of props and state. It should " + + "never access something that requires stale data from the previous " + + "render, such as refs. Move this logic to componentDidMount and " + + "componentDidUpdate instead.", + getComponentName(owner.type) || "A component" + ); + } + owner.stateNode._warnedAboutRefsInRender = true; } } @@ -24734,17 +24160,17 @@ function findNodeHandle(componentOrHandle) { var owner = ReactCurrentOwner.current; if (owner !== null && owner.stateNode !== null) { - !owner.stateNode._warnedAboutRefsInRender - ? warningWithoutStack$1( - false, - "%s is accessing findNodeHandle inside its render(). " + - "render() should be a pure function of props and state. It should " + - "never access something that requires stale data from the previous " + - "render, such as refs. Move this logic to componentDidMount and " + - "componentDidUpdate instead.", - getComponentName(owner.type) || "A component" - ) - : void 0; + if (!owner.stateNode._warnedAboutRefsInRender) { + error( + "%s is accessing findNodeHandle inside its render(). " + + "render() should be a pure function of props and state. It should " + + "never access something that requires stale data from the previous " + + "render, such as refs. Move this logic to componentDidMount and " + + "componentDidUpdate instead.", + getComponentName(owner.type) || "A component" + ); + } + owner.stateNode._warnedAboutRefsInRender = true; } } @@ -24796,31 +24222,36 @@ setBatchingImplementation( ); var roots = new Map(); var ReactFabric = { - NativeComponent: ReactNativeComponent$1(findNodeHandle, findHostInstance), + NativeComponent: ReactNativeComponent(findNodeHandle, findHostInstance), // This is needed for implementation details of TouchableNativeFeedback // Remove this once TouchableNativeFeedback doesn't use cloneElement findHostInstance_DEPRECATED: findHostInstance_DEPRECATED, findNodeHandle: findNodeHandle, dispatchCommand: function(handle, command, args) { - var invalid = - handle._nativeTag == null || handle._internalInstanceHandle == null; - - if (invalid) { - !!invalid - ? warningWithoutStack$1( - false, - "dispatchCommand was called with a ref that isn't a " + - "native component. Use React.forwardRef to get access to the underlying native component" - ) - : void 0; + if (handle._nativeTag == null) { + { + error( + "dispatchCommand was called with a ref that isn't a " + + "native component. Use React.forwardRef to get access to the underlying native component" + ); + } + return; } - fabricDispatchCommand( - handle._internalInstanceHandle.stateNode.node, - command, - args - ); + if (handle._internalInstanceHandle) { + nativeFabricUIManager.dispatchCommand( + handle._internalInstanceHandle.stateNode.node, + command, + args + ); + } else { + ReactNativePrivateInterface.UIManager.dispatchViewManagerCommand( + handle._nativeTag, + command, + args + ); + } }, render: function(element, containerTag, callback) { var root = roots.get(containerTag); diff --git a/Libraries/Renderer/implementations/ReactFabric-dev.js b/Libraries/Renderer/implementations/ReactFabric-dev.js index 1d431cb1a3de42..398cab778a59af 100644 --- a/Libraries/Renderer/implementations/ReactFabric-dev.js +++ b/Libraries/Renderer/implementations/ReactFabric-dev.js @@ -16,13 +16,110 @@ if (__DEV__) { (function() { "use strict"; +var React = require("react"); require("react-native/Libraries/ReactPrivate/ReactNativePrivateInitializeCore"); var ReactNativePrivateInterface = require("react-native/Libraries/ReactPrivate/ReactNativePrivateInterface"); -var React = require("react"); -var Scheduler = require("scheduler"); var checkPropTypes = require("prop-types/checkPropTypes"); +var Scheduler = require("scheduler"); var tracing = require("scheduler/tracing"); +var ReactSharedInternals = + React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED; // Prevent newer renderers from RTE when used with older react package versions. +// Current owner and dispatcher used to share the same ref, +// but PR #14548 split them out to better support the react-debug-tools package. + +if (!ReactSharedInternals.hasOwnProperty("ReactCurrentDispatcher")) { + ReactSharedInternals.ReactCurrentDispatcher = { + current: null + }; +} + +if (!ReactSharedInternals.hasOwnProperty("ReactCurrentBatchConfig")) { + ReactSharedInternals.ReactCurrentBatchConfig = { + suspense: null + }; +} + +// by calls to these methods by a Babel plugin. +// +// In PROD (or in packages without access to React internals), +// they are left as they are instead. + +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]; + } + + 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]; + } + + printWarning("error", format, args); + } +} + +function printWarning(level, format, args) { + // When changing this logic, you might want to also + // update consoleWithStackDev.www.js as well. + { + var hasExistingStack = + args.length > 0 && + typeof args[args.length - 1] === "string" && + args[args.length - 1].indexOf("\n in") === 0; + + if (!hasExistingStack) { + var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame; + var stack = ReactDebugCurrentFrame.getStackAddendum(); + + if (stack !== "") { + format += "%s"; + args = args.concat([stack]); + } + } + + var argsWithFormat = args.map(function(item) { + return "" + item; + }); // Careful: RN currently depends on this prefix + + argsWithFormat.unshift("Warning: " + format); // We intentionally don't use spread (or .apply) directly because it + // breaks IE9: https://github.com/facebook/react/issues/13610 + // eslint-disable-next-line react-internal/no-production-logging + + Function.prototype.apply.call(console[level], console, argsWithFormat); + + try { + // --- Welcome to debugging React --- + // This error was thrown as a convenience so that you can use this stack + // to find the callsite that caused this warning to fire. + var argIndex = 0; + var message = + "Warning: " + + format.replace(/%s/g, function() { + return args[argIndex++]; + }); + throw new Error(message); + } catch (x) {} + } +} + /** * Use invariant() to assert state which your program assumes to be true. * @@ -560,71 +657,6 @@ function clearCaughtError() { } } -/** - * Similar to invariant but only logs a warning if the condition is not met. - * This can be used to log issues in development environments in critical - * paths. Removing the logging code for production environments will keep the - * same logic and follow the same code paths. - */ -var warningWithoutStack = function() {}; - -{ - warningWithoutStack = function(condition, format) { - for ( - var _len = arguments.length, - args = new Array(_len > 2 ? _len - 2 : 0), - _key = 2; - _key < _len; - _key++ - ) { - args[_key - 2] = arguments[_key]; - } - - if (format === undefined) { - throw new Error( - "`warningWithoutStack(condition, format, ...args)` requires a warning " + - "message argument" - ); - } - - if (args.length > 8) { - // Check before the condition to catch violations early. - throw new Error( - "warningWithoutStack() currently supports at most 8 arguments." - ); - } - - if (condition) { - return; - } - - if (typeof console !== "undefined") { - var argsWithFormat = args.map(function(item) { - return "" + item; - }); - argsWithFormat.unshift("Warning: " + format); // We intentionally don't use spread (or .apply) directly because it - // breaks IE9: https://github.com/facebook/react/issues/13610 - - Function.prototype.apply.call(console.error, console, argsWithFormat); - } - - try { - // --- Welcome to debugging React --- - // This error was thrown as a convenience so that you can use this stack - // to find the callsite that caused this warning to fire. - var argIndex = 0; - var message = - "Warning: " + - format.replace(/%s/g, function() { - return args[argIndex++]; - }); - throw new Error(message); - } catch (x) {} - }; -} - -var warningWithoutStack$1 = warningWithoutStack; - var getFiberCurrentPropsFromNode = null; var getInstanceFromNode = null; var getNodeFromInstance = null; @@ -638,13 +670,12 @@ function setComponentTree( getNodeFromInstance = getNodeFromInstanceImpl; { - !(getNodeFromInstance && getInstanceFromNode) - ? warningWithoutStack$1( - false, - "EventPluginUtils.setComponentTree(...): Injected " + - "module is missing getNodeFromInstance or getInstanceFromNode." - ) - : void 0; + if (!getNodeFromInstance || !getInstanceFromNode) { + error( + "EventPluginUtils.setComponentTree(...): Injected " + + "module is missing getNodeFromInstance or getInstanceFromNode." + ); + } } } var validateEventDispatches; @@ -665,9 +696,10 @@ var validateEventDispatches; : dispatchInstances ? 1 : 0; - !(instancesIsArr === listenersIsArr && instancesLen === listenersLen) - ? warningWithoutStack$1(false, "EventPluginUtils: Invalid `event`.") - : void 0; + + if (instancesIsArr !== listenersIsArr || instancesLen !== listenersLen) { + error("EventPluginUtils: Invalid `event`."); + } }; } /** @@ -1094,6 +1126,7 @@ var DehydratedFragment = 18; var SuspenseListComponent = 19; var FundamentalComponent = 20; var ScopeComponent = 21; +var Chunk = 22; function getParent(inst) { do { @@ -1231,9 +1264,9 @@ function listenerAtPhase(inst, event, propagationPhase) { function accumulateDirectionalDispatches(inst, phase, event) { { - !inst - ? warningWithoutStack$1(false, "Dispatching inst must not be null") - : void 0; + if (!inst) { + error("Dispatching inst must not be null"); + } } var listener = listenerAtPhase(inst, event, phase); @@ -1578,7 +1611,7 @@ function getPooledWarningPropertyDefinition(propName, getVal) { function set(val) { var action = isFunction ? "setting the method" : "setting the property"; - warn(action, "This is effectively a no-op"); + warn$$1(action, "This is effectively a no-op"); return val; } @@ -1587,24 +1620,22 @@ function getPooledWarningPropertyDefinition(propName, getVal) { var result = isFunction ? "This is a no-op function" : "This is set to null"; - warn(action, result); + warn$$1(action, result); return getVal; } - function warn(action, result) { - var warningCondition = false; - !warningCondition - ? warningWithoutStack$1( - false, - "This synthetic event is reused for performance reasons. If you're seeing this, " + - "you're %s `%s` on a released/nullified synthetic event. %s. " + - "If you must keep the original synthetic event around, use event.persist(). " + - "See https://fb.me/react-event-pooling for more information.", - action, - propName, - result - ) - : void 0; + function warn$$1(action, result) { + { + error( + "This synthetic event is reused for performance reasons. If you're seeing this, " + + "you're %s `%s` on a released/nullified synthetic event. %s. " + + "If you must keep the original synthetic event around, use event.persist(). " + + "See https://fb.me/react-event-pooling for more information.", + action, + propName, + result + ); + } } } @@ -1749,15 +1780,14 @@ function getTouchIdentifier(_ref) { } { - !(identifier <= MAX_TOUCH_BANK) - ? warningWithoutStack$1( - false, - "Touch identifier %s is greater than maximum supported %s which causes " + - "performance issues backfilling array locations for all of the indices.", - identifier, - MAX_TOUCH_BANK - ) - : void 0; + if (identifier > MAX_TOUCH_BANK) { + error( + "Touch identifier %s is greater than maximum supported %s which causes " + + "performance issues backfilling array locations for all of the indices.", + identifier, + MAX_TOUCH_BANK + ); + } } return identifier; @@ -1789,12 +1819,15 @@ function recordTouchMove(touch) { touchRecord.currentTimeStamp = timestampForTouch(touch); touchHistory.mostRecentTimeStamp = timestampForTouch(touch); } else { - console.warn( - "Cannot record touch move without a touch start.\n" + "Touch Move: %s\n", - "Touch Bank: %s", - printTouch(touch), - printTouchBank() - ); + { + warn( + "Cannot record touch move without a touch start.\n" + + "Touch Move: %s\n" + + "Touch Bank: %s", + printTouch(touch), + printTouchBank() + ); + } } } @@ -1811,12 +1844,15 @@ function recordTouchEnd(touch) { touchRecord.currentTimeStamp = timestampForTouch(touch); touchHistory.mostRecentTimeStamp = timestampForTouch(touch); } else { - console.warn( - "Cannot record touch end without a touch start.\n" + "Touch End: %s\n", - "Touch Bank: %s", - printTouch(touch), - printTouchBank() - ); + { + warn( + "Cannot record touch end without a touch start.\n" + + "Touch End: %s\n" + + "Touch Bank: %s", + printTouch(touch), + printTouchBank() + ); + } } } @@ -1867,9 +1903,10 @@ var ResponderTouchHistoryStore = { { var activeRecord = touchBank[touchHistory.indexOfSingleActiveTouch]; - !(activeRecord != null && activeRecord.touchActive) - ? warningWithoutStack$1(false, "Cannot find single active touch.") - : void 0; + + if (activeRecord == null || !activeRecord.touchActive) { + error("Cannot find single active touch."); + } } } } @@ -2398,9 +2435,12 @@ var ResponderEventPlugin = { if (trackedTouchCount >= 0) { trackedTouchCount -= 1; } else { - console.warn( - "Ended a touch event which was not counted in `trackedTouchCount`." - ); + { + warn( + "Ended a touch event which was not counted in `trackedTouchCount`." + ); + } + return null; } } @@ -2575,7 +2615,9 @@ var enableProfilerTimer = true; var enableSchedulerTracing = true; var enableSuspenseServerRenderer = false; -var enableFlareAPI = false; +var enableChunksAPI = false; + +var enableDeprecatedFlareAPI = false; var enableFundamentalAPI = false; var enableScopeAPI = false; @@ -2586,6 +2628,7 @@ var warnAboutDefaultPropsOnFunctionComponents = false; var warnAboutStringRefs = false; var disableLegacyContext = false; var disableSchedulerTimeoutBasedOnReactExpirationTime = false; +var enableTrainModelFix = false; var enableNativeTargetAsInstance = false; // Only used in www builds. @@ -2667,23 +2710,6 @@ function set(key, value) { key._reactInternalFiber = value; } -var ReactSharedInternals = - React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED; // Prevent newer renderers from RTE when used with older react package versions. -// Current owner and dispatcher used to share the same ref, -// but PR #14548 split them out to better support the react-debug-tools package. - -if (!ReactSharedInternals.hasOwnProperty("ReactCurrentDispatcher")) { - ReactSharedInternals.ReactCurrentDispatcher = { - current: null - }; -} - -if (!ReactSharedInternals.hasOwnProperty("ReactCurrentBatchConfig")) { - ReactSharedInternals.ReactCurrentBatchConfig = { - suspense: null - }; -} - // The Symbol used to tag the ReactElement-like types. If there is no native Symbol // nor polyfill, then a plain number is used for performance. var hasSymbol = typeof Symbol === "function" && Symbol.for; @@ -2710,6 +2736,7 @@ var REACT_SUSPENSE_LIST_TYPE = hasSymbol : 0xead8; var REACT_MEMO_TYPE = hasSymbol ? Symbol.for("react.memo") : 0xead3; var REACT_LAZY_TYPE = hasSymbol ? Symbol.for("react.lazy") : 0xead4; +var REACT_CHUNK_TYPE = hasSymbol ? Symbol.for("react.chunk") : 0xead9; var REACT_FUNDAMENTAL_TYPE = hasSymbol ? Symbol.for("react.fundamental") : 0xead5; @@ -2733,43 +2760,6 @@ function getIteratorFn(maybeIterable) { return null; } -/** - * Similar to invariant but only logs a warning if the condition is not met. - * This can be used to log issues in development environments in critical - * paths. Removing the logging code for production environments will keep the - * same logic and follow the same code paths. - */ - -var warning = warningWithoutStack$1; - -{ - warning = function(condition, format) { - if (condition) { - return; - } - - var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame; - var stack = ReactDebugCurrentFrame.getStackAddendum(); // eslint-disable-next-line react-internal/warning-and-invariant-args - - for ( - var _len = arguments.length, - args = new Array(_len > 2 ? _len - 2 : 0), - _key = 2; - _key < _len; - _key++ - ) { - args[_key - 2] = arguments[_key]; - } - - warningWithoutStack$1.apply( - void 0, - [false, format + "%s"].concat(args, [stack]) - ); - }; -} - -var warning$1 = warning; - var Uninitialized = -1; var Pending = 0; var Resolved = 1; @@ -2790,8 +2780,7 @@ function initializeLazyComponentType(lazyComponent) { { if (defaultExport === undefined) { - warning$1( - false, + error( "lazy: Expected the result of a dynamic import() call. " + "Instead received: %s\n\nYour code should look like: \n " + "const MyComponent = lazy(() => import('./MyComponent'))", @@ -2804,10 +2793,10 @@ function initializeLazyComponentType(lazyComponent) { lazyComponent._result = defaultExport; } }, - function(error) { + function(error$$1) { if (lazyComponent._status === Pending) { lazyComponent._status = Rejected; - lazyComponent._result = error; + lazyComponent._result = error$$1; } } ); @@ -2830,8 +2819,7 @@ function getComponentName(type) { { if (typeof type.tag === "number") { - warningWithoutStack$1( - false, + error( "Received an unexpected object in getComponentName(). " + "This is likely a bug in React. Please file an issue." ); @@ -2880,6 +2868,9 @@ function getComponentName(type) { case REACT_MEMO_TYPE: return getComponentName(type.type); + case REACT_CHUNK_TYPE: + return getComponentName(type.render); + case REACT_LAZY_TYPE: { var thenable = type; var resolvedThenable = refineResolvedLazyComponent(thenable); @@ -3003,17 +2994,18 @@ function isMounted(component) { if (owner !== null && owner.tag === ClassComponent) { var ownerFiber = owner; var instance = ownerFiber.stateNode; - !instance._warnedAboutRefsInRender - ? warningWithoutStack$1( - false, - "%s is accessing isMounted inside its render() function. " + - "render() should be a pure function of props and state. It should " + - "never access something that requires stale data from the previous " + - "render, such as refs. Move this logic to componentDidMount and " + - "componentDidUpdate instead.", - getComponentName(ownerFiber.type) || "A component" - ) - : void 0; + + if (!instance._warnedAboutRefsInRender) { + error( + "%s is accessing isMounted inside its render() function. " + + "render() should be a pure function of props and state. It should " + + "never access something that requires stale data from the previous " + + "render, such as refs. Move this logic to componentDidMount and " + + "componentDidUpdate instead.", + getComponentName(ownerFiber.type) || "A component" + ); + } + instance._warnedAboutRefsInRender = true; } } @@ -3281,17 +3273,19 @@ function throwOnStylesProp(component, props) { } } function warnForStyleProps(props, validAttributes) { - for (var key in validAttributes.style) { - if (!(validAttributes[key] || props[key] === undefined)) { - console.error( - "You are setting the style `{ " + - key + - ": ... }` as a prop. You " + - "should nest it in a style object. " + - "E.g. `{ style: { " + - key + - ": ... } }`" - ); + { + for (var key in validAttributes.style) { + if (!(validAttributes[key] || props[key] === undefined)) { + error( + "You are setting the style `{ %s" + + ": ... }` as a prop. You " + + "should nest it in a style object. " + + "E.g. `{ style: { %s" + + ": ... } }`", + key, + key + ); + } } } } @@ -3775,8 +3769,13 @@ function restoreStateOfTarget(target) { ); } - var props = getFiberCurrentPropsFromNode(internalInstance.stateNode); - restoreImpl(internalInstance.stateNode, internalInstance.type, props); + var stateNode = internalInstance.stateNode; // Guard against Fiber being unmounted. + + if (stateNode) { + var _props = getFiberCurrentPropsFromNode(stateNode); + + restoreImpl(internalInstance.stateNode, internalInstance.type, _props); + } } function needsStateRestore() { @@ -3810,16 +3809,9 @@ var batchedUpdatesImpl = function(fn, bookkeeping) { return fn(bookkeeping); }; -var discreteUpdatesImpl = function(fn, a, b, c) { - return fn(a, b, c); -}; - var flushDiscreteUpdatesImpl = function() {}; -var batchedEventUpdatesImpl = batchedUpdatesImpl; var isInsideEventHandler = false; -var isBatchingEventUpdates = false; - function finishEventHandler() { // Here we wait until all updates have propagated, which is important // when using controlled components within layers: @@ -3852,72 +3844,8 @@ function batchedUpdates(fn, bookkeeping) { finishEventHandler(); } } -function batchedEventUpdates(fn, a, b) { - if (isBatchingEventUpdates) { - // If we are currently inside another batch, we need to wait until it - // fully completes before restoring state. - return fn(a, b); - } - - isBatchingEventUpdates = true; - - try { - return batchedEventUpdatesImpl(fn, a, b); - } finally { - isBatchingEventUpdates = false; - finishEventHandler(); - } -} // This is for the React Flare event system - -function executeUserEventHandler(fn, value) { - var previouslyInEventHandler = isInsideEventHandler; - - try { - isInsideEventHandler = true; - var type = typeof value === "object" && value !== null ? value.type : ""; - invokeGuardedCallbackAndCatchFirstError(type, fn, undefined, value); - } finally { - isInsideEventHandler = previouslyInEventHandler; - } -} -function discreteUpdates(fn, a, b, c) { - var prevIsInsideEventHandler = isInsideEventHandler; - isInsideEventHandler = true; +// This is for the React Flare event system - try { - return discreteUpdatesImpl(fn, a, b, c); - } finally { - isInsideEventHandler = prevIsInsideEventHandler; - - if (!isInsideEventHandler) { - finishEventHandler(); - } - } -} -var lastFlushedEventTimeStamp = 0; -function flushDiscreteUpdatesIfNeeded(timeStamp) { - // event.timeStamp isn't overly reliable due to inconsistencies in - // how different browsers have historically provided the time stamp. - // Some browsers provide high-resolution time stamps for all events, - // some provide low-resolution time stamps for all events. FF < 52 - // even mixes both time stamps together. Some browsers even report - // negative time stamps or time stamps that are 0 (iOS9) in some cases. - // Given we are only comparing two time stamps with equality (!==), - // we are safe from the resolution differences. If the time stamp is 0 - // we bail-out of preventing the flush, which can affect semantics, - // such as if an earlier flush removes or adds event listeners that - // are fired in the subsequent flush. However, this is the same - // behaviour as we had before this change, so the risks are low. - if ( - !isInsideEventHandler && - (!enableFlareAPI || - timeStamp === 0 || - lastFlushedEventTimeStamp !== timeStamp) - ) { - lastFlushedEventTimeStamp = timeStamp; - flushDiscreteUpdatesImpl(); - } -} function setBatchingImplementation( _batchedUpdatesImpl, _discreteUpdatesImpl, @@ -3925,501 +3853,43 @@ function setBatchingImplementation( _batchedEventUpdatesImpl ) { batchedUpdatesImpl = _batchedUpdatesImpl; - discreteUpdatesImpl = _discreteUpdatesImpl; flushDiscreteUpdatesImpl = _flushDiscreteUpdatesImpl; - batchedEventUpdatesImpl = _batchedEventUpdatesImpl; -} - -function _inheritsLoose(subClass, superClass) { - subClass.prototype = Object.create(superClass.prototype); - subClass.prototype.constructor = subClass; - subClass.__proto__ = superClass; } -/** - * Class only exists for its Flow type. - */ -var ReactNativeComponent = - /*#__PURE__*/ - (function(_React$Component) { - _inheritsLoose(ReactNativeComponent, _React$Component); +function dispatchEvent(target, topLevelType, nativeEvent) { + var targetFiber = target; + var eventTarget = null; - function ReactNativeComponent() { - return _React$Component.apply(this, arguments) || this; + if (enableNativeTargetAsInstance) { + if (targetFiber != null) { + eventTarget = targetFiber.stateNode.canonical; } + } else { + eventTarget = nativeEvent.target; + } - var _proto = ReactNativeComponent.prototype; - - _proto.blur = function blur() {}; - - _proto.focus = function focus() {}; + batchedUpdates(function() { + // Heritage plugin event system + runExtractedPluginEventsInBatch( + topLevelType, + targetFiber, + nativeEvent, + eventTarget, + PLUGIN_EVENT_SYSTEM + ); + }); // React Native doesn't use ReactControlledComponent but if it did, here's + // where it would do it. +} - _proto.measure = function measure(callback) {}; +// can re-export everything from this module. - _proto.measureInWindow = function measureInWindow(callback) {}; - - _proto.measureLayout = function measureLayout( - relativeToNativeNode, - onSuccess, - onFail - ) {}; - - _proto.setNativeProps = function setNativeProps(nativeProps) {}; - - return ReactNativeComponent; - })(React.Component); // This type is only used for FlowTests. It shouldn't be imported directly - -var DiscreteEvent = 0; -var UserBlockingEvent = 1; -var ContinuousEvent = 2; - -// CommonJS interop named imports. - -var UserBlockingPriority = Scheduler.unstable_UserBlockingPriority; -var runWithPriority = Scheduler.unstable_runWithPriority; -var _nativeFabricUIManage$2 = nativeFabricUIManager; -var measureInWindow = _nativeFabricUIManage$2.measureInWindow; -var rootEventTypesToEventResponderInstances = new Map(); -var currentTimeStamp = 0; -var currentInstance = null; -var eventResponderContext = { - dispatchEvent: function(eventValue, eventListener, eventPriority) { - validateResponderContext(); - validateEventValue(eventValue); - - switch (eventPriority) { - case DiscreteEvent: { - flushDiscreteUpdatesIfNeeded(currentTimeStamp); - discreteUpdates(function() { - return executeUserEventHandler(eventListener, eventValue); - }); - break; - } - - case UserBlockingEvent: { - runWithPriority(UserBlockingPriority, function() { - return executeUserEventHandler(eventListener, eventValue); - }); - break; - } - - case ContinuousEvent: { - executeUserEventHandler(eventListener, eventValue); - break; - } - } - }, - isTargetWithinNode: function(childTarget, parentTarget) { - validateResponderContext(); - var childFiber = getFiberFromTarget(childTarget); - var parentFiber = getFiberFromTarget(parentTarget); - var node = childFiber; - - while (node !== null) { - if (node === parentFiber) { - return true; - } - - node = node.return; - } - - return false; - }, - getTargetBoundingRect: function(target, callback) { - measureInWindow(target.node, function(x, y, width, height) { - callback({ - left: x, - right: x + width, - top: y, - bottom: y + height - }); - }); - }, - addRootEventTypes: function(rootEventTypes) { - validateResponderContext(); - - for (var i = 0; i < rootEventTypes.length; i++) { - var rootEventType = rootEventTypes[i]; - var eventResponderInstance = currentInstance; - registerRootEventType(rootEventType, eventResponderInstance); - } - }, - removeRootEventTypes: function(rootEventTypes) { - validateResponderContext(); - - for (var i = 0; i < rootEventTypes.length; i++) { - var rootEventType = rootEventTypes[i]; - var rootEventResponders = rootEventTypesToEventResponderInstances.get( - rootEventType - ); - var rootEventTypesSet = currentInstance.rootEventTypes; - - if (rootEventTypesSet !== null) { - rootEventTypesSet.delete(rootEventType); - } - - if (rootEventResponders !== undefined) { - rootEventResponders.delete(currentInstance); - } - } - }, - getTimeStamp: function() { - validateResponderContext(); - return currentTimeStamp; - }, - getResponderNode: function() { - validateResponderContext(); - var responderFiber = currentInstance.fiber; - - if (responderFiber.tag === ScopeComponent) { - return null; - } - - return responderFiber.stateNode; - } -}; - -function validateEventValue(eventValue) { - if (typeof eventValue === "object" && eventValue !== null) { - var target = eventValue.target, - type = eventValue.type, - timeStamp = eventValue.timeStamp; - - if (target == null || type == null || timeStamp == null) { - throw new Error( - 'context.dispatchEvent: "target", "timeStamp", and "type" fields on event object are required.' - ); - } - - var showWarning = function(name) { - { - warning$1( - false, - "%s is not available on event objects created from event responder modules (React Flare). " + - 'Try wrapping in a conditional, i.e. `if (event.type !== "press") { event.%s }`', - name, - name - ); - } - }; - - eventValue.preventDefault = function() { - { - showWarning("preventDefault()"); - } - }; - - eventValue.stopPropagation = function() { - { - showWarning("stopPropagation()"); - } - }; - - eventValue.isDefaultPrevented = function() { - { - showWarning("isDefaultPrevented()"); - } - }; - - eventValue.isPropagationStopped = function() { - { - showWarning("isPropagationStopped()"); - } - }; // $FlowFixMe: we don't need value, Flow thinks we do - - Object.defineProperty(eventValue, "nativeEvent", { - get: function() { - { - showWarning("nativeEvent"); - } - } - }); - } -} - -function getFiberFromTarget(target) { - if (target === null) { - return null; - } - - return target.canonical._internalInstanceHandle || null; -} - -function createFabricResponderEvent(topLevelType, nativeEvent, target) { - return { - nativeEvent: nativeEvent, - target: target, - type: topLevelType - }; -} - -function validateResponderContext() { - if (!currentInstance) { - throw Error( - "An event responder context was used outside of an event cycle." - ); - } -} // TODO this function is almost an exact copy of the DOM version, we should -// somehow share the logic - -function responderEventTypesContainType(eventTypes, type) { - for (var i = 0, len = eventTypes.length; i < len; i++) { - if (eventTypes[i] === type) { - return true; - } - } - - return false; -} - -function validateResponderTargetEventTypes(eventType, responder) { - var targetEventTypes = responder.targetEventTypes; // Validate the target event type exists on the responder - - if (targetEventTypes !== null) { - return responderEventTypesContainType(targetEventTypes, eventType); - } - - return false; -} // TODO this function is almost an exact copy of the DOM version, we should -// somehow share the logic - -function traverseAndHandleEventResponderInstances( - eventType, - targetFiber, - nativeEvent -) { - // Trigger event responders in this order: - // - Bubble target responder phase - // - Root responder phase - var responderEvent = createFabricResponderEvent( - eventType, - nativeEvent, - targetFiber !== null ? targetFiber.stateNode : null - ); - var visitedResponders = new Set(); - var node = targetFiber; - - while (node !== null) { - var _node = node, - dependencies = _node.dependencies, - tag = _node.tag; - - if ( - (tag === HostComponent || tag === ScopeComponent) && - dependencies !== null - ) { - var respondersMap = dependencies.responders; - - if (respondersMap !== null) { - var responderInstances = Array.from(respondersMap.values()); - - for (var i = 0, length = responderInstances.length; i < length; i++) { - var responderInstance = responderInstances[i]; - var props = responderInstance.props, - responder = responderInstance.responder, - state = responderInstance.state; - - if ( - !visitedResponders.has(responder) && - validateResponderTargetEventTypes(eventType, responder) - ) { - var onEvent = responder.onEvent; - visitedResponders.add(responder); - - if (onEvent !== null) { - currentInstance = responderInstance; - onEvent(responderEvent, eventResponderContext, props, state); - } - } - } - } - } - - node = node.return; - } // Root phase - - var rootEventResponderInstances = rootEventTypesToEventResponderInstances.get( - eventType - ); - - if (rootEventResponderInstances !== undefined) { - var _responderInstances = Array.from(rootEventResponderInstances); - - for (var _i = 0; _i < _responderInstances.length; _i++) { - var _responderInstance = _responderInstances[_i]; - var props = _responderInstance.props, - responder = _responderInstance.responder, - state = _responderInstance.state; - var onRootEvent = responder.onRootEvent; - - if (onRootEvent !== null) { - currentInstance = _responderInstance; - onRootEvent(responderEvent, eventResponderContext, props, state); - } - } - } -} // TODO this function is almost an exact copy of the DOM version, we should -// somehow share the logic - -function dispatchEventForResponderEventSystem( - topLevelType, - targetFiber, - nativeEvent -) { - var previousInstance = currentInstance; - var previousTimeStamp = currentTimeStamp; // We might want to control timeStamp another way here - - currentTimeStamp = Date.now(); - - try { - batchedEventUpdates(function() { - traverseAndHandleEventResponderInstances( - topLevelType, - targetFiber, - nativeEvent - ); - }); - } finally { - currentInstance = previousInstance; - currentTimeStamp = previousTimeStamp; - } -} // TODO this function is almost an exact copy of the DOM version, we should -// somehow share the logic - -function mountEventResponder(responder, responderInstance, props, state) { - var onMount = responder.onMount; - - if (onMount !== null) { - currentInstance = responderInstance; - - try { - batchedEventUpdates(function() { - onMount(eventResponderContext, props, state); - }); - } finally { - currentInstance = null; - } - } -} // TODO this function is almost an exact copy of the DOM version, we should -// somehow share the logic - -function unmountEventResponder(responderInstance) { - var responder = responderInstance.responder; - var onUnmount = responder.onUnmount; - - if (onUnmount !== null) { - var props = responderInstance.props, - state = responderInstance.state; - currentInstance = responderInstance; - - try { - batchedEventUpdates(function() { - onUnmount(eventResponderContext, props, state); - }); - } finally { - currentInstance = null; - } - } - - var rootEventTypesSet = responderInstance.rootEventTypes; - - if (rootEventTypesSet !== null) { - var rootEventTypes = Array.from(rootEventTypesSet); - - for (var i = 0; i < rootEventTypes.length; i++) { - var topLevelEventType = rootEventTypes[i]; - var rootEventResponderInstances = rootEventTypesToEventResponderInstances.get( - topLevelEventType - ); - - if (rootEventResponderInstances !== undefined) { - rootEventResponderInstances.delete(responderInstance); - } - } - } -} - -function registerRootEventType(rootEventType, responderInstance) { - var rootEventResponderInstances = rootEventTypesToEventResponderInstances.get( - rootEventType - ); - - if (rootEventResponderInstances === undefined) { - rootEventResponderInstances = new Set(); - rootEventTypesToEventResponderInstances.set( - rootEventType, - rootEventResponderInstances - ); - } - - var rootEventTypesSet = responderInstance.rootEventTypes; - - if (rootEventTypesSet === null) { - rootEventTypesSet = responderInstance.rootEventTypes = new Set(); - } - - if (!!rootEventTypesSet.has(rootEventType)) { - throw Error( - 'addRootEventTypes() found a duplicate root event type of "' + - rootEventType + - '". This might be because the event type exists in the event responder "rootEventTypes" array or because of a previous addRootEventTypes() using this root event type.' - ); - } - - rootEventTypesSet.add(rootEventType); - rootEventResponderInstances.add(responderInstance); -} - -function addRootEventTypesForResponderInstance( - responderInstance, - rootEventTypes -) { - for (var i = 0; i < rootEventTypes.length; i++) { - var rootEventType = rootEventTypes[i]; - registerRootEventType(rootEventType, responderInstance); - } -} - -function dispatchEvent(target, topLevelType, nativeEvent) { - var targetFiber = target; - - if (enableFlareAPI) { - // React Flare event system - dispatchEventForResponderEventSystem(topLevelType, target, nativeEvent); - } - - var eventTarget = null; - - if (enableNativeTargetAsInstance) { - if (targetFiber != null) { - eventTarget = targetFiber.stateNode.canonical; - } - } else { - eventTarget = nativeEvent.target; - } - - batchedUpdates(function() { - // Heritage plugin event system - runExtractedPluginEventsInBatch( - topLevelType, - targetFiber, - nativeEvent, - eventTarget, - PLUGIN_EVENT_SYSTEM - ); - }); // React Native doesn't use ReactControlledComponent but if it did, here's - // where it would do it. -} - -// 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." - ); - } -} // Mutation (when unsupported) +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." + ); + } +} // Mutation (when unsupported) var supportsMutation = false; var appendChild = shim; @@ -4475,21 +3945,21 @@ var didNotFindHydratableInstance = shim$1; var didNotFindHydratableTextInstance = shim$1; var didNotFindHydratableSuspenseInstance = shim$1; -var _nativeFabricUIManage$1 = nativeFabricUIManager; -var createNode = _nativeFabricUIManage$1.createNode; -var cloneNode = _nativeFabricUIManage$1.cloneNode; -var cloneNodeWithNewChildren = _nativeFabricUIManage$1.cloneNodeWithNewChildren; +var _nativeFabricUIManage = nativeFabricUIManager; +var createNode = _nativeFabricUIManage.createNode; +var cloneNode = _nativeFabricUIManage.cloneNode; +var cloneNodeWithNewChildren = _nativeFabricUIManage.cloneNodeWithNewChildren; var cloneNodeWithNewChildrenAndProps = - _nativeFabricUIManage$1.cloneNodeWithNewChildrenAndProps; -var cloneNodeWithNewProps = _nativeFabricUIManage$1.cloneNodeWithNewProps; -var createChildNodeSet = _nativeFabricUIManage$1.createChildSet; -var appendChildNode = _nativeFabricUIManage$1.appendChild; -var appendChildNodeToSet = _nativeFabricUIManage$1.appendChildToSet; -var completeRoot = _nativeFabricUIManage$1.completeRoot; -var registerEventHandler = _nativeFabricUIManage$1.registerEventHandler; -var fabricMeasure = _nativeFabricUIManage$1.measure; -var fabricMeasureInWindow = _nativeFabricUIManage$1.measureInWindow; -var fabricMeasureLayout = _nativeFabricUIManage$1.measureLayout; + _nativeFabricUIManage.cloneNodeWithNewChildrenAndProps; +var cloneNodeWithNewProps = _nativeFabricUIManage.cloneNodeWithNewProps; +var createChildNodeSet = _nativeFabricUIManage.createChildSet; +var appendChildNode = _nativeFabricUIManage.appendChild; +var appendChildNodeToSet = _nativeFabricUIManage.appendChildToSet; +var completeRoot = _nativeFabricUIManage.completeRoot; +var registerEventHandler = _nativeFabricUIManage.registerEventHandler; +var fabricMeasure = _nativeFabricUIManage.measure; +var fabricMeasureInWindow = _nativeFabricUIManage.measureInWindow; +var fabricMeasureLayout = _nativeFabricUIManage.measureLayout; var getViewConfigForType = ReactNativePrivateInterface.ReactNativeViewConfigRegistry.get; // Counter for uniquely identifying views. // % 10 === 1 means it is a rootTag. @@ -4560,10 +4030,12 @@ var ReactFabricHostComponent = typeof relativeToNativeNode === "number" || !(relativeToNativeNode instanceof ReactFabricHostComponent) ) { - warningWithoutStack$1( - false, - "Warning: ref.measureLayout must be called with a ref to a native component." - ); + { + error( + "Warning: ref.measureLayout must be called with a ref to a native component." + ); + } + return; } @@ -4576,10 +4048,10 @@ var ReactFabricHostComponent = }; _proto.setNativeProps = function setNativeProps(nativeProps) { - warningWithoutStack$1( - false, - "Warning: setNativeProps is not currently supported in Fabric" - ); + { + error("Warning: setNativeProps is not currently supported in Fabric"); + } + return; }; @@ -4794,28 +4266,17 @@ function finalizeContainerChildren(container, newChildren) { completeRoot(container, newChildren); } -function mountResponderInstance( +function DEPRECATED_mountResponderInstance( responder, responderInstance, props, state, instance ) { - if (enableFlareAPI) { - var rootEventTypes = responder.rootEventTypes; - - if (rootEventTypes !== null) { - addRootEventTypesForResponderInstance(responderInstance, rootEventTypes); - } - - mountEventResponder(responder, responderInstance, props, state); - } + throw new Error("Not yet implemented."); } -function unmountResponderInstance(responderInstance) { - if (enableFlareAPI) { - // TODO stop listening to targetEventTypes - unmountEventResponder(responderInstance); - } +function DEPRECATED_unmountResponderInstance(responderInstance) { + throw new Error("Not yet implemented."); } function getFundamentalComponentInstance(fundamentalInstance) { throw new Error("Not yet implemented."); @@ -4838,6 +4299,9 @@ function cloneFundamentalInstance(fundamentalInstance) { function getInstanceFromNode$1(node) { throw new Error("Not yet implemented."); } +function beforeRemoveInstance(instance) { + // noop +} var BEFORE_SLASH_RE = /^(.*)[\\\/]/; var describeComponentFrame = function(name, source, ownerName) { @@ -5421,7 +4885,7 @@ function createCursor(defaultValue) { function pop(cursor, fiber) { if (index < 0) { { - warningWithoutStack$1(false, "Unexpected pop."); + error("Unexpected pop."); } return; @@ -5429,7 +4893,7 @@ function pop(cursor, fiber) { { if (fiber !== fiberStack[index]) { - warningWithoutStack$1(false, "Unexpected Fiber popped."); + error("Unexpected Fiber popped."); } } @@ -5616,8 +5080,8 @@ function processChildContext(fiber, type, parentContext) { if (!warnedAboutMissingGetChildContext[componentName]) { warnedAboutMissingGetChildContext[componentName] = true; - warningWithoutStack$1( - false, + + error( "%s.childContextTypes is specified but there is no getChildContext() method " + "on the instance. You can either define getChildContext() on %s or remove " + "childContextTypes from it.", @@ -5816,7 +5280,7 @@ var fakeCallbackNode = {}; // Except for NoPriority, these correspond to Schedul // avoid clashing with Scheduler's priorities. var ImmediatePriority = 99; -var UserBlockingPriority$1 = 98; +var UserBlockingPriority = 98; var NormalPriority = 97; var LowPriority = 96; var IdlePriority = 95; // NoPriority is the absence of priority. Also React-only. @@ -5848,7 +5312,7 @@ function getCurrentPriorityLevel() { return ImmediatePriority; case Scheduler_UserBlockingPriority: - return UserBlockingPriority$1; + return UserBlockingPriority; case Scheduler_NormalPriority: return NormalPriority; @@ -5870,7 +5334,7 @@ function reactPriorityToSchedulerPriority(reactPriorityLevel) { case ImmediatePriority: return Scheduler_ImmediatePriority; - case UserBlockingPriority$1: + case UserBlockingPriority: return Scheduler_UserBlockingPriority; case NormalPriority: @@ -5888,7 +5352,7 @@ function reactPriorityToSchedulerPriority(reactPriorityLevel) { } } -function runWithPriority$1(reactPriorityLevel, fn) { +function runWithPriority(reactPriorityLevel, fn) { var priorityLevel = reactPriorityToSchedulerPriority(reactPriorityLevel); return Scheduler_runWithPriority(priorityLevel, fn); } @@ -5938,7 +5402,7 @@ function flushSyncCallbackQueueImpl() { try { var _isSync = true; var queue = syncQueue; - runWithPriority$1(ImmediatePriority, function() { + runWithPriority(ImmediatePriority, function() { for (; i < queue.length; i++) { var callback = queue[i]; @@ -6073,7 +5537,7 @@ function inferPriorityFromExpirationTime(currentTime, expirationTime) { } if (msUntil <= HIGH_PRIORITY_EXPIRATION + HIGH_PRIORITY_BATCH_SIZE) { - return UserBlockingPriority$1; + return UserBlockingPriority; } if (msUntil <= LOW_PRIORITY_EXPIRATION + LOW_PRIORITY_BATCH_SIZE) { @@ -6136,78 +5600,6 @@ function shallowEqual(objA, objB) { return true; } -/** - * Forked from fbjs/warning: - * https://github.com/facebook/fbjs/blob/e66ba20ad5be433eb54423f2b097d829324d9de6/packages/fbjs/src/__forks__/warning.js - * - * Only change is we use console.warn instead of console.error, - * and do nothing when 'console' is not supported. - * This really simplifies the code. - * --- - * Similar to invariant but only logs a warning if the condition is not met. - * This can be used to log issues in development environments in critical - * paths. Removing the logging code for production environments will keep the - * same logic and follow the same code paths. - */ -var lowPriorityWarningWithoutStack = function() {}; - -{ - var printWarning = function(format) { - for ( - var _len = arguments.length, - args = new Array(_len > 1 ? _len - 1 : 0), - _key = 1; - _key < _len; - _key++ - ) { - args[_key - 1] = arguments[_key]; - } - - var argIndex = 0; - var message = - "Warning: " + - format.replace(/%s/g, function() { - return args[argIndex++]; - }); - - if (typeof console !== "undefined") { - console.warn(message); - } - - try { - // --- Welcome to debugging React --- - // This error was thrown as a convenience so that you can use this stack - // to find the callsite that caused this warning to fire. - throw new Error(message); - } catch (x) {} - }; - - lowPriorityWarningWithoutStack = function(condition, format) { - if (format === undefined) { - throw new Error( - "`lowPriorityWarningWithoutStack(condition, format, ...args)` requires a warning " + - "message argument" - ); - } - - if (!condition) { - for ( - var _len2 = arguments.length, - args = new Array(_len2 > 2 ? _len2 - 2 : 0), - _key2 = 2; - _key2 < _len2; - _key2++ - ) { - args[_key2 - 2] = arguments[_key2]; - } - - printWarning.apply(void 0, [format].concat(args)); - } - }; -} - -var lowPriorityWarningWithoutStack$1 = lowPriorityWarningWithoutStack; - var ReactStrictModeWarnings = { recordUnsafeLifecycleWarnings: function(fiber, instance) {}, flushPendingUnsafeLifecycleWarnings: function() {}, @@ -6378,8 +5770,8 @@ var ReactStrictModeWarnings = { if (UNSAFE_componentWillMountUniqueNames.size > 0) { var sortedNames = setToSortedString(UNSAFE_componentWillMountUniqueNames); - warningWithoutStack$1( - false, + + error( "Using UNSAFE_componentWillMount in strict mode is not recommended and may indicate bugs in your code. " + "See https://fb.me/react-unsafe-component-lifecycles for details.\n\n" + "* Move code with side effects to componentDidMount, and set initial state in the constructor.\n" + @@ -6393,8 +5785,7 @@ var ReactStrictModeWarnings = { UNSAFE_componentWillReceivePropsUniqueNames ); - warningWithoutStack$1( - false, + error( "Using UNSAFE_componentWillReceiveProps in strict mode is not recommended " + "and may indicate bugs in your code. " + "See https://fb.me/react-unsafe-component-lifecycles for details.\n\n" + @@ -6412,8 +5803,7 @@ var ReactStrictModeWarnings = { UNSAFE_componentWillUpdateUniqueNames ); - warningWithoutStack$1( - false, + error( "Using UNSAFE_componentWillUpdate in strict mode is not recommended " + "and may indicate bugs in your code. " + "See https://fb.me/react-unsafe-component-lifecycles for details.\n\n" + @@ -6426,8 +5816,7 @@ var ReactStrictModeWarnings = { if (componentWillMountUniqueNames.size > 0) { var _sortedNames3 = setToSortedString(componentWillMountUniqueNames); - lowPriorityWarningWithoutStack$1( - false, + warn( "componentWillMount has been renamed, and is not recommended for use. " + "See https://fb.me/react-unsafe-component-lifecycles for details.\n\n" + "* Move code with side effects to componentDidMount, and set initial state in the constructor.\n" + @@ -6445,8 +5834,7 @@ var ReactStrictModeWarnings = { componentWillReceivePropsUniqueNames ); - lowPriorityWarningWithoutStack$1( - false, + warn( "componentWillReceiveProps has been renamed, and is not recommended for use. " + "See https://fb.me/react-unsafe-component-lifecycles for details.\n\n" + "* Move data fetching code or side effects to componentDidUpdate.\n" + @@ -6465,8 +5853,7 @@ var ReactStrictModeWarnings = { if (componentWillUpdateUniqueNames.size > 0) { var _sortedNames5 = setToSortedString(componentWillUpdateUniqueNames); - lowPriorityWarningWithoutStack$1( - false, + warn( "componentWillUpdate has been renamed, and is not recommended for use. " + "See https://fb.me/react-unsafe-component-lifecycles for details.\n\n" + "* Move data fetching code or side effects to componentDidUpdate.\n" + @@ -6491,11 +5878,11 @@ var ReactStrictModeWarnings = { var strictRoot = findStrictRoot(fiber); if (strictRoot === null) { - warningWithoutStack$1( - false, + error( "Expected to find a StrictMode component in a strict mode tree. " + "This error is likely caused by a bug in React. Please file an issue." ); + return; } // Dedup strategy: Warn once per component. @@ -6528,8 +5915,8 @@ var ReactStrictModeWarnings = { }); var sortedNames = setToSortedString(uniqueNames); var strictRootComponentStack = getStackByFiberInDevAndProd(strictRoot); - warningWithoutStack$1( - false, + + error( "Legacy context API has been detected within a strict-mode tree." + "\n\nThe old API will be supported in all 16.x releases, but applications " + "using it should migrate to the new version." + @@ -7062,17 +6449,17 @@ function pushProvider(providerFiber, nextValue) { context._currentValue = nextValue; { - !( - context._currentRenderer === undefined || - context._currentRenderer === null || - context._currentRenderer === rendererSigil - ) - ? warningWithoutStack$1( - false, - "Detected multiple renderers concurrently rendering the " + - "same context provider. This is currently unsupported." - ) - : void 0; + if ( + context._currentRenderer !== undefined && + context._currentRenderer !== null && + context._currentRenderer !== rendererSigil + ) { + error( + "Detected multiple renderers concurrently rendering the " + + "same context provider. This is currently unsupported." + ); + } + context._currentRenderer = rendererSigil; } } else { @@ -7080,17 +6467,17 @@ function pushProvider(providerFiber, nextValue) { context._currentValue2 = nextValue; { - !( - context._currentRenderer2 === undefined || - context._currentRenderer2 === null || - context._currentRenderer2 === rendererSigil - ) - ? warningWithoutStack$1( - false, - "Detected multiple renderers concurrently rendering the " + - "same context provider. This is currently unsupported." - ) - : void 0; + if ( + context._currentRenderer2 !== undefined && + context._currentRenderer2 !== null && + context._currentRenderer2 !== rendererSigil + ) { + error( + "Detected multiple renderers concurrently rendering the " + + "same context provider. This is currently unsupported." + ); + } + context._currentRenderer2 = rendererSigil; } } @@ -7117,14 +6504,13 @@ function calculateChangedBits(context, newValue, oldValue) { : MAX_SIGNED_31_BIT_INT; { - !((changedBits & MAX_SIGNED_31_BIT_INT) === changedBits) - ? warning$1( - false, - "calculateChangedBits: Expected the return value to be a " + - "31-bit integer. Instead received: %s", - changedBits - ) - : void 0; + if ((changedBits & MAX_SIGNED_31_BIT_INT) !== changedBits) { + error( + "calculateChangedBits: Expected the return value to be a " + + "31-bit integer. Instead received: %s", + changedBits + ); + } } return changedBits | 0; @@ -7320,15 +6706,14 @@ function readContext(context, observedBits) { { // This warning would fire if you read context inside a Hook like useMemo. // Unlike the class check below, it's not enforced in production for perf. - !!isDisallowedContextReadInDEV - ? warning$1( - false, - "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()." - ) - : void 0; + if (isDisallowedContextReadInDEV) { + 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 (lastContextWithAllBitsObserved === context) { @@ -7469,38 +6854,32 @@ var currentlyProcessingQueue; currentlyProcessingQueue = null; } -function createUpdateQueue(baseState) { - var queue = { - baseState: baseState, - firstUpdate: null, - lastUpdate: null, - firstCapturedUpdate: null, - lastCapturedUpdate: null, - firstEffect: null, - lastEffect: null, - firstCapturedEffect: null, - lastCapturedEffect: null - }; - return queue; -} - -function cloneUpdateQueue(currentQueue) { +function initializeUpdateQueue(fiber) { var queue = { - baseState: currentQueue.baseState, - firstUpdate: currentQueue.firstUpdate, - lastUpdate: currentQueue.lastUpdate, - // TODO: With resuming, if we bail out and resuse the child tree, we should - // keep these effects. - firstCapturedUpdate: null, - lastCapturedUpdate: null, - firstEffect: null, - lastEffect: null, - firstCapturedEffect: null, - lastCapturedEffect: null + baseState: fiber.memoizedState, + baseQueue: null, + shared: { + pending: null + }, + effects: null }; - return queue; + fiber.updateQueue = queue; +} +function cloneUpdateQueue(current, workInProgress) { + // Clone the update queue from current. Unless it's already a clone. + var queue = workInProgress.updateQueue; + var currentQueue = current.updateQueue; + + if (queue === currentQueue) { + var clone = { + baseState: currentQueue.baseState, + baseQueue: currentQueue.baseQueue, + shared: currentQueue.shared, + effects: currentQueue.effects + }; + workInProgress.updateQueue = clone; + } } - function createUpdate(expirationTime, suspenseConfig) { var update = { expirationTime: expirationTime, @@ -7508,9 +6887,9 @@ function createUpdate(expirationTime, suspenseConfig) { tag: UpdateState, payload: null, callback: null, - next: null, - nextEffect: null + next: null }; + update.next = update; { update.priority = getCurrentPriorityLevel(); @@ -7518,136 +6897,62 @@ function createUpdate(expirationTime, suspenseConfig) { return update; } +function enqueueUpdate(fiber, update) { + var updateQueue = fiber.updateQueue; -function appendUpdateToQueue(queue, update) { - // Append the update to the end of the list. - if (queue.lastUpdate === null) { - // Queue is empty - queue.firstUpdate = queue.lastUpdate = update; - } else { - queue.lastUpdate.next = update; - queue.lastUpdate = update; + if (updateQueue === null) { + // Only occurs if the fiber has been unmounted. + return; } -} -function enqueueUpdate(fiber, update) { - // Update queues are created lazily. - var alternate = fiber.alternate; - var queue1; - var queue2; + var sharedQueue = updateQueue.shared; + var pending = sharedQueue.pending; - if (alternate === null) { - // There's only one fiber. - queue1 = fiber.updateQueue; - queue2 = null; - - if (queue1 === null) { - queue1 = fiber.updateQueue = createUpdateQueue(fiber.memoizedState); - } + if (pending === null) { + // This is the first update. Create a circular list. + update.next = update; } else { - // There are two owners. - queue1 = fiber.updateQueue; - queue2 = alternate.updateQueue; - - if (queue1 === null) { - if (queue2 === null) { - // Neither fiber has an update queue. Create new ones. - queue1 = fiber.updateQueue = createUpdateQueue(fiber.memoizedState); - queue2 = alternate.updateQueue = createUpdateQueue( - alternate.memoizedState - ); - } else { - // Only one fiber has an update queue. Clone to create a new one. - queue1 = fiber.updateQueue = cloneUpdateQueue(queue2); - } - } else { - if (queue2 === null) { - // Only one fiber has an update queue. Clone to create a new one. - queue2 = alternate.updateQueue = cloneUpdateQueue(queue1); - } else { - // Both owners have an update queue. - } - } + update.next = pending.next; + pending.next = update; } - if (queue2 === null || queue1 === queue2) { - // There's only a single queue. - appendUpdateToQueue(queue1, update); - } else { - // There are two queues. We need to append the update to both queues, - // while accounting for the persistent structure of the list — we don't - // want the same update to be added multiple times. - if (queue1.lastUpdate === null || queue2.lastUpdate === null) { - // One of the queues is not empty. We must add the update to both queues. - appendUpdateToQueue(queue1, update); - appendUpdateToQueue(queue2, update); - } else { - // Both queues are non-empty. The last update is the same in both lists, - // because of structural sharing. So, only append to one of the lists. - appendUpdateToQueue(queue1, update); // But we still need to update the `lastUpdate` pointer of queue2. - - queue2.lastUpdate = update; - } - } + sharedQueue.pending = update; { if ( - fiber.tag === ClassComponent && - (currentlyProcessingQueue === queue1 || - (queue2 !== null && currentlyProcessingQueue === queue2)) && + currentlyProcessingQueue === sharedQueue && !didWarnUpdateInsideUpdate ) { - warningWithoutStack$1( - false, + error( "An update (setState, replaceState, or forceUpdate) was scheduled " + "from inside an update function. Update functions should be pure, " + "with zero side-effects. Consider using componentDidUpdate or a " + "callback." ); + didWarnUpdateInsideUpdate = true; } } } function enqueueCapturedUpdate(workInProgress, update) { - // Captured updates go into a separate list, and only on the work-in- - // progress queue. - var workInProgressQueue = workInProgress.updateQueue; + var current = workInProgress.alternate; - if (workInProgressQueue === null) { - workInProgressQueue = workInProgress.updateQueue = createUpdateQueue( - workInProgress.memoizedState - ); - } else { - // TODO: I put this here rather than createWorkInProgress so that we don't - // clone the queue unnecessarily. There's probably a better way to - // structure this. - workInProgressQueue = ensureWorkInProgressQueueIsAClone( - workInProgress, - workInProgressQueue - ); - } // Append the update to the end of the list. + if (current !== null) { + // Ensure the work-in-progress queue is a clone + cloneUpdateQueue(current, workInProgress); + } // Captured updates go only on the work-in-progress queue. - if (workInProgressQueue.lastCapturedUpdate === null) { - // This is the first render phase update - workInProgressQueue.firstCapturedUpdate = workInProgressQueue.lastCapturedUpdate = update; - } else { - workInProgressQueue.lastCapturedUpdate.next = update; - workInProgressQueue.lastCapturedUpdate = update; - } -} + var queue = workInProgress.updateQueue; // Append the update to the end of the list. -function ensureWorkInProgressQueueIsAClone(workInProgress, queue) { - var current = workInProgress.alternate; + var last = queue.baseQueue; - if (current !== null) { - // If the work-in-progress queue is equal to the current queue, - // we need to clone it first. - if (queue === current.updateQueue) { - queue = workInProgress.updateQueue = cloneUpdateQueue(queue); - } + if (last === null) { + queue.baseQueue = update.next = update; + update.next = update; + } else { + update.next = last.next; + last.next = update; } - - return queue; } function getStateFromUpdate( @@ -7739,163 +7044,171 @@ function getStateFromUpdate( function processUpdateQueue( workInProgress, - queue, props, instance, renderExpirationTime ) { + // This is always non-null on a ClassComponent or HostRoot + var queue = workInProgress.updateQueue; hasForceUpdate = false; - queue = ensureWorkInProgressQueueIsAClone(workInProgress, queue); { - currentlyProcessingQueue = queue; - } // These values may change as we process the queue. + currentlyProcessingQueue = queue.shared; + } // The last rebase update that is NOT part of the base state. + + var baseQueue = queue.baseQueue; // The last pending update that hasn't been processed yet. - var newBaseState = queue.baseState; - var newFirstUpdate = null; - var newExpirationTime = NoWork; // Iterate through the list of updates to compute the result. + var pendingQueue = queue.shared.pending; - var update = queue.firstUpdate; - var resultState = newBaseState; + if (pendingQueue !== null) { + // We have new updates that haven't been processed yet. + // We'll add them to the base queue. + if (baseQueue !== null) { + // Merge the pending queue and the base queue. + var baseFirst = baseQueue.next; + var pendingFirst = pendingQueue.next; + baseQueue.next = pendingFirst; + pendingQueue.next = baseFirst; + } - while (update !== null) { - var updateExpirationTime = update.expirationTime; + baseQueue = pendingQueue; + queue.shared.pending = null; // TODO: Pass `current` as argument - if (updateExpirationTime < renderExpirationTime) { - // This update does not have sufficient priority. Skip it. - if (newFirstUpdate === null) { - // This is the first skipped update. It will be the first update in - // the new list. - newFirstUpdate = update; // Since this is the first update that was skipped, the current result - // is the new base state. + var current = workInProgress.alternate; - newBaseState = resultState; - } // Since this update will remain in the list, update the remaining - // expiration time. + if (current !== null) { + var currentQueue = current.updateQueue; - if (newExpirationTime < updateExpirationTime) { - newExpirationTime = updateExpirationTime; + if (currentQueue !== null) { + currentQueue.baseQueue = pendingQueue; } - } else { - // This update does have sufficient priority. - // Mark the event time of this update as relevant to this render pass. - // TODO: This should ideally use the true event time of this update rather than - // its priority which is a derived and not reverseable value. - // TODO: We should skip this update if it was already committed but currently - // we have no way of detecting the difference between a committed and suspended - // update here. - markRenderEventTimeAndConfig(updateExpirationTime, update.suspenseConfig); // Process it and compute a new result. - - resultState = getStateFromUpdate( - workInProgress, - queue, - update, - resultState, - props, - instance - ); - var callback = update.callback; + } + } // These values may change as we process the queue. - if (callback !== null) { - workInProgress.effectTag |= Callback; // Set this to null, in case it was mutated during an aborted render. + if (baseQueue !== null) { + var first = baseQueue.next; // Iterate through the list of updates to compute the result. - update.nextEffect = null; + var newState = queue.baseState; + var newExpirationTime = NoWork; + var newBaseState = null; + var newBaseQueueFirst = null; + var newBaseQueueLast = null; - if (queue.lastEffect === null) { - queue.firstEffect = queue.lastEffect = update; - } else { - queue.lastEffect.nextEffect = update; - queue.lastEffect = update; - } - } - } // Continue to the next update. + if (first !== null) { + var update = first; - update = update.next; - } // Separately, iterate though the list of captured updates. + do { + var updateExpirationTime = update.expirationTime; + + if (updateExpirationTime < renderExpirationTime) { + // Priority is insufficient. Skip this update. If this is the first + // skipped update, the previous update/state is the new base + // update/state. + var clone = { + expirationTime: update.expirationTime, + suspenseConfig: update.suspenseConfig, + tag: update.tag, + payload: update.payload, + callback: update.callback, + next: null + }; - var newFirstCapturedUpdate = null; - update = queue.firstCapturedUpdate; + if (newBaseQueueLast === null) { + newBaseQueueFirst = newBaseQueueLast = clone; + newBaseState = newState; + } else { + newBaseQueueLast = newBaseQueueLast.next = clone; + } // Update the remaining priority in the queue. - while (update !== null) { - var _updateExpirationTime = update.expirationTime; + if (updateExpirationTime > newExpirationTime) { + newExpirationTime = updateExpirationTime; + } + } else { + // This update does have sufficient priority. + if (newBaseQueueLast !== null) { + var _clone = { + expirationTime: Sync, + // This update is going to be committed so we never want uncommit it. + suspenseConfig: update.suspenseConfig, + tag: update.tag, + payload: update.payload, + callback: update.callback, + next: null + }; + newBaseQueueLast = newBaseQueueLast.next = _clone; + } // Mark the event time of this update as relevant to this render pass. + // TODO: This should ideally use the true event time of this update rather than + // its priority which is a derived and not reverseable value. + // TODO: We should skip this update if it was already committed but currently + // we have no way of detecting the difference between a committed and suspended + // update here. + + markRenderEventTimeAndConfig( + updateExpirationTime, + update.suspenseConfig + ); // Process this update. + + newState = getStateFromUpdate( + workInProgress, + queue, + update, + newState, + props, + instance + ); + var callback = update.callback; - if (_updateExpirationTime < renderExpirationTime) { - // This update does not have sufficient priority. Skip it. - if (newFirstCapturedUpdate === null) { - // This is the first skipped captured update. It will be the first - // update in the new list. - newFirstCapturedUpdate = update; // If this is the first update that was skipped, the current result is - // the new base state. + if (callback !== null) { + workInProgress.effectTag |= Callback; + var effects = queue.effects; - if (newFirstUpdate === null) { - newBaseState = resultState; + if (effects === null) { + queue.effects = [update]; + } else { + effects.push(update); + } + } } - } // Since this update will remain in the list, update the remaining - // expiration time. - if (newExpirationTime < _updateExpirationTime) { - newExpirationTime = _updateExpirationTime; - } - } else { - // This update does have sufficient priority. Process it and compute - // a new result. - resultState = getStateFromUpdate( - workInProgress, - queue, - update, - resultState, - props, - instance - ); - var _callback = update.callback; + update = update.next; - if (_callback !== null) { - workInProgress.effectTag |= Callback; // Set this to null, in case it was mutated during an aborted render. + if (update === null || update === first) { + pendingQueue = queue.shared.pending; - update.nextEffect = null; - - if (queue.lastCapturedEffect === null) { - queue.firstCapturedEffect = queue.lastCapturedEffect = update; - } else { - queue.lastCapturedEffect.nextEffect = update; - queue.lastCapturedEffect = update; + if (pendingQueue === null) { + break; + } else { + // An update was scheduled from inside a reducer. Add the new + // pending updates to the end of the list and keep processing. + update = baseQueue.next = pendingQueue.next; + pendingQueue.next = first; + queue.baseQueue = baseQueue = pendingQueue; + queue.shared.pending = null; + } } - } + } while (true); } - update = update.next; - } - - if (newFirstUpdate === null) { - queue.lastUpdate = null; - } + if (newBaseQueueLast === null) { + newBaseState = newState; + } else { + newBaseQueueLast.next = newBaseQueueFirst; + } - if (newFirstCapturedUpdate === null) { - queue.lastCapturedUpdate = null; - } else { - workInProgress.effectTag |= Callback; - } + queue.baseState = newBaseState; + queue.baseQueue = newBaseQueueLast; // Set the remaining expiration time to be whatever is remaining in the queue. + // This should be fine because the only two other things that contribute to + // expiration time are props and context. We're already in the middle of the + // begin phase by the time we start processing the queue, so we've already + // dealt with the props. Context in components that specify + // shouldComponentUpdate is tricky; but we'll have to account for + // that regardless. - if (newFirstUpdate === null && newFirstCapturedUpdate === null) { - // We processed every update, without skipping. That means the new base - // state is the same as the result state. - newBaseState = resultState; + markUnprocessedUpdateTime(newExpirationTime); + workInProgress.expirationTime = newExpirationTime; + workInProgress.memoizedState = newState; } - queue.baseState = newBaseState; - queue.firstUpdate = newFirstUpdate; - queue.firstCapturedUpdate = newFirstCapturedUpdate; // Set the remaining expiration time to be whatever is remaining in the queue. - // This should be fine because the only two other things that contribute to - // expiration time are props and context. We're already in the middle of the - // begin phase by the time we start processing the queue, so we've already - // dealt with the props. Context in components that specify - // shouldComponentUpdate is tricky; but we'll have to account for - // that regardless. - - markUnprocessedUpdateTime(newExpirationTime); - workInProgress.expirationTime = newExpirationTime; - workInProgress.memoizedState = resultState; - { currentlyProcessingQueue = null; } @@ -7924,36 +7237,20 @@ function commitUpdateQueue( instance, renderExpirationTime ) { - // If the finished render included captured updates, and there are still - // lower priority updates left over, we need to keep the captured updates - // in the queue so that they are rebased and not dropped once we process the - // queue again at the lower priority. - if (finishedQueue.firstCapturedUpdate !== null) { - // Join the captured update list to the end of the normal list. - if (finishedQueue.lastUpdate !== null) { - finishedQueue.lastUpdate.next = finishedQueue.firstCapturedUpdate; - finishedQueue.lastUpdate = finishedQueue.lastCapturedUpdate; - } // Clear the list of captured updates. - - finishedQueue.firstCapturedUpdate = finishedQueue.lastCapturedUpdate = null; - } // Commit the effects - - commitUpdateEffects(finishedQueue.firstEffect, instance); - finishedQueue.firstEffect = finishedQueue.lastEffect = null; - commitUpdateEffects(finishedQueue.firstCapturedEffect, instance); - finishedQueue.firstCapturedEffect = finishedQueue.lastCapturedEffect = null; -} - -function commitUpdateEffects(effect, instance) { - while (effect !== null) { - var callback = effect.callback; + // Commit the effects + var effects = finishedQueue.effects; + finishedQueue.effects = null; - if (callback !== null) { - effect.callback = null; - callCallback(callback, instance); - } + if (effects !== null) { + for (var i = 0; i < effects.length; i++) { + var effect = effects[i]; + var callback = effect.callback; - effect = effect.nextEffect; + if (callback !== null) { + effect.callback = null; + callCallback(callback, instance); + } + } } } @@ -7998,8 +7295,8 @@ var didWarnAboutInvalidateContextType; if (!didWarnOnInvalidCallback.has(key)) { didWarnOnInvalidCallback.add(key); - warningWithoutStack$1( - false, + + error( "%s(...): Expected the last optional `callback` argument to be a " + "function. Instead received: %s.", callerName, @@ -8014,8 +7311,8 @@ var didWarnAboutInvalidateContextType; if (!didWarnAboutUndefinedDerivedState.has(componentName)) { didWarnAboutUndefinedDerivedState.add(componentName); - warningWithoutStack$1( - false, + + error( "%s.getDerivedStateFromProps(): A valid state object (or null) must be returned. " + "You have returned undefined.", componentName @@ -8072,9 +7369,9 @@ function applyDerivedStateFromProps( workInProgress.memoizedState = memoizedState; // Once the update queue is empty, persist the derived state onto the // base state. - var updateQueue = workInProgress.updateQueue; - - if (updateQueue !== null && workInProgress.expirationTime === NoWork) { + if (workInProgress.expirationTime === NoWork) { + // Queue is always non-null for classes + var updateQueue = workInProgress.updateQueue; updateQueue.baseState = memoizedState; } } @@ -8173,14 +7470,13 @@ function checkShouldComponentUpdate( stopPhaseTimer(); { - !(shouldUpdate !== undefined) - ? warningWithoutStack$1( - false, - "%s.shouldComponentUpdate(): Returned undefined instead of a " + - "boolean value. Make sure to return true or false.", - getComponentName(ctor) || "Component" - ) - : void 0; + if (shouldUpdate === undefined) { + error( + "%s.shouldComponentUpdate(): Returned undefined instead of a " + + "boolean value. Make sure to return true or false.", + getComponentName(ctor) || "Component" + ); + } } return shouldUpdate; @@ -8204,15 +7500,13 @@ function checkClassInstance(workInProgress, ctor, newProps) { if (!renderPresent) { if (ctor.prototype && typeof ctor.prototype.render === "function") { - warningWithoutStack$1( - false, + error( "%s(...): No `render` method found on the returned component " + "instance: did you accidentally return an object from the constructor?", name ); } else { - warningWithoutStack$1( - false, + error( "%s(...): No `render` method found on the returned component " + "instance: you may have forgotten to define `render`.", name @@ -8220,54 +7514,50 @@ function checkClassInstance(workInProgress, ctor, newProps) { } } - var noGetInitialStateOnES6 = - !instance.getInitialState || - instance.getInitialState.isReactClassApproved || - instance.state; - !noGetInitialStateOnES6 - ? warningWithoutStack$1( - false, - "getInitialState was defined on %s, a plain JavaScript class. " + - "This is only supported for classes created using React.createClass. " + - "Did you mean to define a state property instead?", - name - ) - : void 0; - var noGetDefaultPropsOnES6 = - !instance.getDefaultProps || - instance.getDefaultProps.isReactClassApproved; - !noGetDefaultPropsOnES6 - ? warningWithoutStack$1( - false, - "getDefaultProps was defined on %s, a plain JavaScript class. " + - "This is only supported for classes created using React.createClass. " + - "Use a static property to define defaultProps instead.", - name - ) - : void 0; - var noInstancePropTypes = !instance.propTypes; - !noInstancePropTypes - ? warningWithoutStack$1( - false, - "propTypes was defined as an instance property on %s. Use a static " + - "property to define propTypes instead.", - name - ) - : void 0; - var noInstanceContextType = !instance.contextType; - !noInstanceContextType - ? warningWithoutStack$1( - false, - "contextType was defined as an instance property on %s. Use a static " + - "property to define contextType instead.", - name - ) - : void 0; + if ( + instance.getInitialState && + !instance.getInitialState.isReactClassApproved && + !instance.state + ) { + error( + "getInitialState was defined on %s, a plain JavaScript class. " + + "This is only supported for classes created using React.createClass. " + + "Did you mean to define a state property instead?", + name + ); + } + + if ( + instance.getDefaultProps && + !instance.getDefaultProps.isReactClassApproved + ) { + error( + "getDefaultProps was defined on %s, a plain JavaScript class. " + + "This is only supported for classes created using React.createClass. " + + "Use a static property to define defaultProps instead.", + name + ); + } + + if (instance.propTypes) { + error( + "propTypes was defined as an instance property on %s. Use a static " + + "property to define propTypes instead.", + name + ); + } + + if (instance.contextType) { + error( + "contextType was defined as an instance property on %s. Use a static " + + "property to define contextType instead.", + name + ); + } if (disableLegacyContext) { if (ctor.childContextTypes) { - warningWithoutStack$1( - false, + error( "%s uses the legacy childContextTypes API which is no longer supported. " + "Use React.createContext() instead.", name @@ -8275,23 +7565,20 @@ function checkClassInstance(workInProgress, ctor, newProps) { } if (ctor.contextTypes) { - warningWithoutStack$1( - false, + error( "%s uses the legacy contextTypes API which is no longer supported. " + "Use React.createContext() with static contextType instead.", name ); } } else { - var noInstanceContextTypes = !instance.contextTypes; - !noInstanceContextTypes - ? warningWithoutStack$1( - false, - "contextTypes was defined as an instance property on %s. Use a static " + - "property to define contextTypes instead.", - name - ) - : void 0; + if (instance.contextTypes) { + error( + "contextTypes was defined as an instance property on %s. Use a static " + + "property to define contextTypes instead.", + name + ); + } if ( ctor.contextType && @@ -8299,8 +7586,8 @@ function checkClassInstance(workInProgress, ctor, newProps) { !didWarnAboutContextTypeAndContextTypes.has(ctor) ) { didWarnAboutContextTypeAndContextTypes.add(ctor); - warningWithoutStack$1( - false, + + error( "%s declares both contextTypes and contextType static properties. " + "The legacy contextTypes property will be ignored.", name @@ -8308,26 +7595,22 @@ function checkClassInstance(workInProgress, ctor, newProps) { } } - var noComponentShouldUpdate = - typeof instance.componentShouldUpdate !== "function"; - !noComponentShouldUpdate - ? warningWithoutStack$1( - false, - "%s has a method called " + - "componentShouldUpdate(). Did you mean shouldComponentUpdate()? " + - "The name is phrased as a question because the function is " + - "expected to return a value.", - name - ) - : void 0; + if (typeof instance.componentShouldUpdate === "function") { + error( + "%s has a method called " + + "componentShouldUpdate(). Did you mean shouldComponentUpdate()? " + + "The name is phrased as a question because the function is " + + "expected to return a value.", + name + ); + } if ( ctor.prototype && ctor.prototype.isPureReactComponent && typeof instance.shouldComponentUpdate !== "undefined" ) { - warningWithoutStack$1( - false, + error( "%s has a method called shouldComponentUpdate(). " + "shouldComponentUpdate should not be used when extending React.PureComponent. " + "Please extend React.Component if shouldComponentUpdate is used.", @@ -8335,70 +7618,61 @@ function checkClassInstance(workInProgress, ctor, newProps) { ); } - var noComponentDidUnmount = - typeof instance.componentDidUnmount !== "function"; - !noComponentDidUnmount - ? warningWithoutStack$1( - false, - "%s has a method called " + - "componentDidUnmount(). But there is no such lifecycle method. " + - "Did you mean componentWillUnmount()?", - name - ) - : void 0; - var noComponentDidReceiveProps = - typeof instance.componentDidReceiveProps !== "function"; - !noComponentDidReceiveProps - ? warningWithoutStack$1( - false, - "%s has a method called " + - "componentDidReceiveProps(). But there is no such lifecycle method. " + - "If you meant to update the state in response to changing props, " + - "use componentWillReceiveProps(). If you meant to fetch data or " + - "run side-effects or mutations after React has updated the UI, use componentDidUpdate().", - name - ) - : void 0; - var noComponentWillRecieveProps = - typeof instance.componentWillRecieveProps !== "function"; - !noComponentWillRecieveProps - ? warningWithoutStack$1( - false, - "%s has a method called " + - "componentWillRecieveProps(). Did you mean componentWillReceiveProps()?", - name - ) - : void 0; - var noUnsafeComponentWillRecieveProps = - typeof instance.UNSAFE_componentWillRecieveProps !== "function"; - !noUnsafeComponentWillRecieveProps - ? warningWithoutStack$1( - false, - "%s has a method called " + - "UNSAFE_componentWillRecieveProps(). Did you mean UNSAFE_componentWillReceiveProps()?", - name - ) - : void 0; + if (typeof instance.componentDidUnmount === "function") { + error( + "%s has a method called " + + "componentDidUnmount(). But there is no such lifecycle method. " + + "Did you mean componentWillUnmount()?", + name + ); + } + + if (typeof instance.componentDidReceiveProps === "function") { + error( + "%s has a method called " + + "componentDidReceiveProps(). But there is no such lifecycle method. " + + "If you meant to update the state in response to changing props, " + + "use componentWillReceiveProps(). If you meant to fetch data or " + + "run side-effects or mutations after React has updated the UI, use componentDidUpdate().", + name + ); + } + + if (typeof instance.componentWillRecieveProps === "function") { + error( + "%s has a method called " + + "componentWillRecieveProps(). Did you mean componentWillReceiveProps()?", + name + ); + } + + if (typeof instance.UNSAFE_componentWillRecieveProps === "function") { + error( + "%s has a method called " + + "UNSAFE_componentWillRecieveProps(). Did you mean UNSAFE_componentWillReceiveProps()?", + name + ); + } + var hasMutatedProps = instance.props !== newProps; - !(instance.props === undefined || !hasMutatedProps) - ? warningWithoutStack$1( - false, - "%s(...): When calling super() in `%s`, make sure to pass " + - "up the same props that your component's constructor was passed.", - name, - name - ) - : void 0; - var noInstanceDefaultProps = !instance.defaultProps; - !noInstanceDefaultProps - ? warningWithoutStack$1( - false, - "Setting defaultProps as an instance property on %s is not supported and will be ignored." + - " Instead, define defaultProps as a static property on %s.", - name, - name - ) - : void 0; + + if (instance.props !== undefined && hasMutatedProps) { + error( + "%s(...): When calling super() in `%s`, make sure to pass " + + "up the same props that your component's constructor was passed.", + name, + name + ); + } + + if (instance.defaultProps) { + error( + "Setting defaultProps as an instance property on %s is not supported and will be ignored." + + " Instead, define defaultProps as a static property on %s.", + name, + name + ); + } if ( typeof instance.getSnapshotBeforeUpdate === "function" && @@ -8406,63 +7680,53 @@ function checkClassInstance(workInProgress, ctor, newProps) { !didWarnAboutGetSnapshotBeforeUpdateWithoutDidUpdate.has(ctor) ) { didWarnAboutGetSnapshotBeforeUpdateWithoutDidUpdate.add(ctor); - warningWithoutStack$1( - false, + + error( "%s: getSnapshotBeforeUpdate() should be used with componentDidUpdate(). " + "This component defines getSnapshotBeforeUpdate() only.", getComponentName(ctor) ); } - var noInstanceGetDerivedStateFromProps = - typeof instance.getDerivedStateFromProps !== "function"; - !noInstanceGetDerivedStateFromProps - ? warningWithoutStack$1( - false, - "%s: getDerivedStateFromProps() is defined as an instance method " + - "and will be ignored. Instead, declare it as a static method.", - name - ) - : void 0; - var noInstanceGetDerivedStateFromCatch = - typeof instance.getDerivedStateFromError !== "function"; - !noInstanceGetDerivedStateFromCatch - ? warningWithoutStack$1( - false, - "%s: getDerivedStateFromError() is defined as an instance method " + - "and will be ignored. Instead, declare it as a static method.", - name - ) - : void 0; - var noStaticGetSnapshotBeforeUpdate = - typeof ctor.getSnapshotBeforeUpdate !== "function"; - !noStaticGetSnapshotBeforeUpdate - ? warningWithoutStack$1( - false, - "%s: getSnapshotBeforeUpdate() is defined as a static method " + - "and will be ignored. Instead, declare it as an instance method.", - name - ) - : void 0; - var _state = instance.state; + if (typeof instance.getDerivedStateFromProps === "function") { + error( + "%s: getDerivedStateFromProps() is defined as an instance method " + + "and will be ignored. Instead, declare it as a static method.", + name + ); + } - if (_state && (typeof _state !== "object" || isArray$1(_state))) { - warningWithoutStack$1( - false, - "%s.state: must be set to an object or null", + if (typeof instance.getDerivedStateFromError === "function") { + error( + "%s: getDerivedStateFromError() is defined as an instance method " + + "and will be ignored. Instead, declare it as a static method.", name ); } - if (typeof instance.getChildContext === "function") { - !(typeof ctor.childContextTypes === "object") - ? warningWithoutStack$1( - false, - "%s.getChildContext(): childContextTypes must be defined in order to " + - "use getChildContext().", - name - ) - : void 0; + if (typeof ctor.getSnapshotBeforeUpdate === "function") { + error( + "%s: getSnapshotBeforeUpdate() is defined as a static method " + + "and will be ignored. Instead, declare it as an instance method.", + name + ); + } + + var _state = instance.state; + + if (_state && (typeof _state !== "object" || isArray$1(_state))) { + error("%s.state: must be set to an object or null", name); + } + + if ( + typeof instance.getChildContext === "function" && + typeof ctor.childContextTypes !== "object" + ) { + error( + "%s.getChildContext(): childContextTypes must be defined in order to " + + "use getChildContext().", + name + ); } } } @@ -8521,8 +7785,7 @@ function constructClassInstance( "}."; } - warningWithoutStack$1( - false, + error( "%s defines an invalid contextType. " + "contextType should point to the Context object returned by React.createContext().%s", getComponentName(ctor) || "Component", @@ -8566,8 +7829,8 @@ function constructClassInstance( if (!didWarnAboutUninitializedState.has(componentName)) { didWarnAboutUninitializedState.add(componentName); - warningWithoutStack$1( - false, + + error( "`%s` uses `getDerivedStateFromProps` but its initial state is " + "%s. This is not recommended. Instead, define the initial state by " + "assigning an object to `this.state` in the constructor of `%s`. " + @@ -8632,8 +7895,8 @@ function constructClassInstance( if (!didWarnAboutLegacyLifecyclesAndDerivedState.has(_componentName)) { didWarnAboutLegacyLifecyclesAndDerivedState.add(_componentName); - warningWithoutStack$1( - false, + + error( "Unsafe legacy lifecycles will not be called for components using new component APIs.\n\n" + "%s uses %s but also contains the following legacy lifecycles:%s%s%s\n\n" + "The above lifecycles should be removed. Learn more about this warning here:\n" + @@ -8675,8 +7938,7 @@ function callComponentWillMount(workInProgress, instance) { if (oldState !== instance.state) { { - warningWithoutStack$1( - false, + error( "%s.componentWillMount(): Assigning directly to this.state is " + "deprecated (except inside a component's " + "constructor). Use setState instead.", @@ -8713,8 +7975,8 @@ function callComponentWillReceiveProps( if (!didWarnAboutStateAssignmentForComponent.has(componentName)) { didWarnAboutStateAssignmentForComponent.add(componentName); - warningWithoutStack$1( - false, + + error( "%s.componentWillReceiveProps(): Assigning directly to " + "this.state is deprecated (except inside a component's " + "constructor). Use setState instead.", @@ -8741,6 +8003,7 @@ function mountClassInstance( instance.props = newProps; instance.state = workInProgress.memoizedState; instance.refs = emptyRefsObject; + initializeUpdateQueue(workInProgress); var contextType = ctor.contextType; if (typeof contextType === "object" && contextType !== null) { @@ -8758,8 +8021,8 @@ function mountClassInstance( if (!didWarnAboutDirectlyAssigningPropsToState.has(componentName)) { didWarnAboutDirectlyAssigningPropsToState.add(componentName); - warningWithoutStack$1( - false, + + error( "%s: It is not recommended to assign props directly to state " + "because updates to props won't be reflected in state. " + "In most cases, it is better to use props directly.", @@ -8783,19 +8046,8 @@ function mountClassInstance( } } - var updateQueue = workInProgress.updateQueue; - - if (updateQueue !== null) { - processUpdateQueue( - workInProgress, - updateQueue, - newProps, - instance, - renderExpirationTime - ); - instance.state = workInProgress.memoizedState; - } - + processUpdateQueue(workInProgress, newProps, instance, renderExpirationTime); + instance.state = workInProgress.memoizedState; var getDerivedStateFromProps = ctor.getDerivedStateFromProps; if (typeof getDerivedStateFromProps === "function") { @@ -8818,18 +8070,13 @@ function mountClassInstance( callComponentWillMount(workInProgress, instance); // If we had additional state updates during this life-cycle, let's // process them now. - updateQueue = workInProgress.updateQueue; - - if (updateQueue !== null) { - processUpdateQueue( - workInProgress, - updateQueue, - newProps, - instance, - renderExpirationTime - ); - instance.state = workInProgress.memoizedState; - } + processUpdateQueue( + workInProgress, + newProps, + instance, + renderExpirationTime + ); + instance.state = workInProgress.memoizedState; } if (typeof instance.componentDidMount === "function") { @@ -8888,18 +8135,8 @@ function resumeMountClassInstance( resetHasForceUpdateBeforeProcessing(); var oldState = workInProgress.memoizedState; var newState = (instance.state = oldState); - var updateQueue = workInProgress.updateQueue; - - if (updateQueue !== null) { - processUpdateQueue( - workInProgress, - updateQueue, - newProps, - instance, - renderExpirationTime - ); - newState = workInProgress.memoizedState; - } + processUpdateQueue(workInProgress, newProps, instance, renderExpirationTime); + newState = workInProgress.memoizedState; if ( oldProps === newProps && @@ -8989,6 +8226,7 @@ function updateClassInstance( renderExpirationTime ) { var instance = workInProgress.stateNode; + cloneUpdateQueue(current, workInProgress); var oldProps = workInProgress.memoizedProps; instance.props = workInProgress.type === workInProgress.elementType @@ -9032,18 +8270,8 @@ function updateClassInstance( resetHasForceUpdateBeforeProcessing(); var oldState = workInProgress.memoizedState; var newState = (instance.state = oldState); - var updateQueue = workInProgress.updateQueue; - - if (updateQueue !== null) { - processUpdateQueue( - workInProgress, - updateQueue, - newProps, - instance, - renderExpirationTime - ); - newState = workInProgress.memoizedState; - } + processUpdateQueue(workInProgress, newProps, instance, renderExpirationTime); + newState = workInProgress.memoizedState; if ( oldProps === newProps && @@ -9205,8 +8433,8 @@ var warnForMissingKey = function(child) {}; } ownerHasKeyUseWarning[currentComponentErrorInfo] = true; - warning$1( - false, + + error( "Each child in a list should have a unique " + '"key" prop. See https://fb.me/react-warning-keys for ' + "more information." @@ -9232,8 +8460,7 @@ function coerceRef(returnFiber, current$$1, element) { if (!didWarnAboutStringRefs[componentName]) { if (warnAboutStringRefs) { - warningWithoutStack$1( - false, + error( 'Component "%s" contains the string ref "%s". Support for string refs ' + "will be removed in a future major release. We recommend using " + "useRef() or createRef() instead. " + @@ -9244,8 +8471,7 @@ function coerceRef(returnFiber, current$$1, element) { getStackByFiberInDevAndProd(returnFiber) ); } else { - warningWithoutStack$1( - false, + error( 'A string ref, "%s", has been found within a strict mode tree. ' + "String refs are a source of potential bugs and should be avoided. " + "We recommend using useRef() or createRef() instead. " + @@ -9358,23 +8584,25 @@ function throwOnInvalidObjectType(returnFiber, newChild) { } function warnOnFunctionType() { - var currentComponentErrorInfo = - "Functions are not valid as a React child. This may happen if " + - "you return a Component instead of from render. " + - "Or maybe you meant to call this function rather than return it." + - getCurrentFiberStackInDev(); + { + var currentComponentErrorInfo = + "Functions are not valid as a React child. This may happen if " + + "you return a Component instead of from render. " + + "Or maybe you meant to call this function rather than return it." + + getCurrentFiberStackInDev(); - if (ownerHasFunctionTypeWarning[currentComponentErrorInfo]) { - return; - } + if (ownerHasFunctionTypeWarning[currentComponentErrorInfo]) { + return; + } - ownerHasFunctionTypeWarning[currentComponentErrorInfo] = true; - warning$1( - false, - "Functions are not valid as a React child. This may happen if " + - "you return a Component instead of from render. " + - "Or maybe you meant to call this function rather than return it." - ); + ownerHasFunctionTypeWarning[currentComponentErrorInfo] = true; + + error( + "Functions are not valid as a React child. This may happen if " + + "you return a Component instead of from render. " + + "Or maybe you meant to call this function rather than return it." + ); + } } // This wrapper function exists because I expect to clone the code in each path // to be able to optimize each path individually by branching early. This needs // a compiler or we can do it manually. Helpers that don't need this branching @@ -9503,44 +8731,62 @@ function ChildReconciler(shouldTrackSideEffects) { ); created.return = returnFiber; return created; - } else { - // Update - var existing = useFiber(current$$1, textContent, expirationTime); - existing.return = returnFiber; - return existing; - } - } - - function updateElement(returnFiber, current$$1, element, expirationTime) { - if ( - current$$1 !== null && - (current$$1.elementType === element.type || // Keep this check inline so it only runs on the false path: - isCompatibleFamilyForHotReloading(current$$1, element)) - ) { - // Move based on index - var existing = useFiber(current$$1, element.props, expirationTime); - existing.ref = coerceRef(returnFiber, current$$1, element); - existing.return = returnFiber; - - { - existing._debugSource = element._source; - existing._debugOwner = element._owner; - } - - return existing; - } else { - // Insert - var created = createFiberFromElement( - element, - returnFiber.mode, - expirationTime - ); - created.ref = coerceRef(returnFiber, current$$1, element); - created.return = returnFiber; - return created; + } else { + // Update + var existing = useFiber(current$$1, textContent, expirationTime); + existing.return = returnFiber; + return existing; } } + function updateElement(returnFiber, current$$1, element, expirationTime) { + if (current$$1 !== null) { + if ( + current$$1.elementType === element.type || // Keep this check inline so it only runs on the false path: + isCompatibleFamilyForHotReloading(current$$1, element) + ) { + // Move based on index + var existing = useFiber(current$$1, element.props, expirationTime); + existing.ref = coerceRef(returnFiber, current$$1, element); + existing.return = returnFiber; + + { + existing._debugSource = element._source; + existing._debugOwner = element._owner; + } + + return existing; + } else if ( + enableChunksAPI && + current$$1.tag === Chunk && + element.type.$$typeof === REACT_CHUNK_TYPE && + element.type.render === current$$1.type.render + ) { + // Same as above but also update the .type field. + var _existing = useFiber(current$$1, element.props, expirationTime); + + _existing.return = returnFiber; + _existing.type = element.type; + + { + _existing._debugSource = element._source; + _existing._debugOwner = element._owner; + } + + return _existing; + } + } // Insert + + var created = createFiberFromElement( + element, + returnFiber.mode, + expirationTime + ); + created.ref = coerceRef(returnFiber, current$$1, element); + created.return = returnFiber; + return created; + } + function updatePortal(returnFiber, current$$1, portal, expirationTime) { if ( current$$1 === null || @@ -9856,8 +9102,7 @@ function ChildReconciler(shouldTrackSideEffects) { break; } - warning$1( - false, + error( "Encountered two children with the same key, `%s`. " + "Keys should be unique so that components maintain their identity " + "across updates. Non-unique keys may cause children to be " + @@ -9865,6 +9110,7 @@ function ChildReconciler(shouldTrackSideEffects) { "could change in a future version.", key ); + break; default: @@ -10070,28 +9316,28 @@ function ChildReconciler(shouldTrackSideEffects) { typeof Symbol === "function" && // $FlowFixMe Flow doesn't know about toStringTag newChildrenIterable[Symbol.toStringTag] === "Generator" ) { - !didWarnAboutGenerators - ? warning$1( - false, - "Using Generators as children is unsupported and will likely yield " + - "unexpected results because enumerating a generator mutates it. " + - "You may convert it to an array with `Array.from()` or the " + - "`[...spread]` operator before rendering. Keep in mind " + - "you might need to polyfill these features for older browsers." - ) - : void 0; + if (!didWarnAboutGenerators) { + error( + "Using Generators as children is unsupported and will likely yield " + + "unexpected results because enumerating a generator mutates it. " + + "You may convert it to an array with `Array.from()` or the " + + "`[...spread]` operator before rendering. Keep in mind " + + "you might need to polyfill these features for older browsers." + ); + } + didWarnAboutGenerators = true; } // Warn about using Maps as children if (newChildrenIterable.entries === iteratorFn) { - !didWarnAboutMaps - ? warning$1( - false, - "Using Maps as children is unsupported and will likely yield " + - "unexpected results. Convert it to a sequence/iterable of keyed " + - "ReactElements instead." - ) - : void 0; + if (!didWarnAboutMaps) { + error( + "Using Maps as children is unsupported and will likely yield " + + "unexpected results. Convert it to a sequence/iterable of keyed " + + "ReactElements instead." + ); + } + didWarnAboutMaps = true; } // First, validate keys. // We'll get a different iterator later for the main pass. @@ -10299,33 +9545,79 @@ function ChildReconciler(shouldTrackSideEffects) { // TODO: If key === null and child.key === null, then this only applies to // the first item in the list. if (child.key === key) { - if ( - child.tag === Fragment - ? element.type === REACT_FRAGMENT_TYPE - : child.elementType === element.type || // Keep this check inline so it only runs on the false path: + switch (child.tag) { + case Fragment: { + if (element.type === REACT_FRAGMENT_TYPE) { + deleteRemainingChildren(returnFiber, child.sibling); + var existing = useFiber( + child, + element.props.children, + expirationTime + ); + existing.return = returnFiber; + + { + existing._debugSource = element._source; + existing._debugOwner = element._owner; + } + + return existing; + } + + break; + } + + case Chunk: + if (enableChunksAPI) { + if ( + element.type.$$typeof === REACT_CHUNK_TYPE && + element.type.render === child.type.render + ) { + deleteRemainingChildren(returnFiber, child.sibling); + + var _existing2 = useFiber(child, element.props, expirationTime); + + _existing2.type = element.type; + _existing2.return = returnFiber; + + { + _existing2._debugSource = element._source; + _existing2._debugOwner = element._owner; + } + + return _existing2; + } + } + + // We intentionally fallthrough here if enableChunksAPI is not on. + // eslint-disable-next-lined no-fallthrough + + default: { + if ( + child.elementType === element.type || // Keep this check inline so it only runs on the false path: isCompatibleFamilyForHotReloading(child, element) - ) { - deleteRemainingChildren(returnFiber, child.sibling); - var existing = useFiber( - child, - element.type === REACT_FRAGMENT_TYPE - ? element.props.children - : element.props, - expirationTime - ); - existing.ref = coerceRef(returnFiber, child, element); - existing.return = returnFiber; + ) { + deleteRemainingChildren(returnFiber, child.sibling); - { - existing._debugSource = element._source; - existing._debugOwner = element._owner; + var _existing3 = useFiber(child, element.props, expirationTime); + + _existing3.ref = coerceRef(returnFiber, child, element); + _existing3.return = returnFiber; + + { + _existing3._debugSource = element._source; + _existing3._debugOwner = element._owner; + } + + return _existing3; + } + + break; } + } // Didn't match. - return existing; - } else { - deleteRemainingChildren(returnFiber, child); - break; - } + deleteRemainingChildren(returnFiber, child); + break; } else { deleteChild(returnFiber, child); } @@ -10781,7 +10073,7 @@ function createResponderInstance( }; } -function mountEventResponder$1( +function mountEventResponder( responder, responderProps, fiber, @@ -10820,7 +10112,7 @@ function mountEventResponder$1( } } - mountResponderInstance( + DEPRECATED_mountResponderInstance( responder, responderInstance, responderProps, @@ -10856,8 +10148,7 @@ function updateEventListener( if (visistedResponders.has(responder)) { // show warning { - warning$1( - false, + error( 'Duplicate event responder "%s" found in event listeners. ' + "Event listeners passed to elements cannot use the same event responder more than once.", responder.displayName @@ -10872,7 +10163,7 @@ function updateEventListener( if (responderInstance === undefined) { // Mount (happens in either complete or commit phase) - mountEventResponder$1( + mountEventResponder( responder, listenerProps, fiber, @@ -10886,7 +10177,11 @@ function updateEventListener( } } -function updateEventListeners(listeners, fiber, rootContainerInstance) { +function updateDeprecatedEventListeners( + listeners, + fiber, + rootContainerInstance +) { var visistedResponders = new Set(); var dependencies = fiber.dependencies; @@ -10902,7 +10197,7 @@ function updateEventListeners(listeners, fiber, rootContainerInstance) { var respondersMap = dependencies.responders; if (respondersMap === null) { - respondersMap = new Map(); + dependencies.responders = respondersMap = new Map(); } if (isArray$2(listeners)) { @@ -10940,7 +10235,7 @@ function updateEventListeners(listeners, fiber, rootContainerInstance) { if (!visistedResponders.has(mountedResponder)) { var responderInstance = _respondersMap.get(mountedResponder); - unmountResponderInstance(responderInstance); + DEPRECATED_unmountResponderInstance(responderInstance); _respondersMap.delete(mountedResponder); } @@ -10948,7 +10243,7 @@ function updateEventListeners(listeners, fiber, rootContainerInstance) { } } } -function createResponderListener(responder, props) { +function createDeprecatedResponderListener(responder, props) { var eventResponderListener = { responder: responder, props: props @@ -10960,6 +10255,24 @@ function createResponderListener(responder, props) { return eventResponderListener; } +function unmountDeprecatedResponderListeners(fiber) { + var dependencies = fiber.dependencies; + + if (dependencies !== null) { + var respondersMap = dependencies.responders; + + if (respondersMap !== null) { + var responderInstances = Array.from(respondersMap.values()); + + for (var i = 0, length = responderInstances.length; i < length; i++) { + var responderInstance = responderInstances[i]; + DEPRECATED_unmountResponderInstance(responderInstance); + } + + dependencies.responders = null; + } + } +} var NoEffect$1 = /* */ @@ -11004,13 +10317,7 @@ var currentlyRenderingFiber$1 = null; // Hooks are stored as a linked list on th // work-in-progress fiber. var currentHook = null; -var nextCurrentHook = null; -var firstWorkInProgressHook = null; -var workInProgressHook = null; -var nextWorkInProgressHook = null; -var remainingExpirationTime = NoWork; -var componentUpdateQueue = null; -var sideEffectTag = 0; // Updates scheduled during render will trigger an immediate re-render at the +var workInProgressHook = null; // Updates scheduled during render will trigger an immediate re-render at the // end of the current pass. We can't store these updates on the normal queue, // because if the work is aborted, they should be discarded. Because this is // a relatively rare case, we also don't want to add an additional field to @@ -11068,8 +10375,7 @@ function checkDepsAreArrayDev(deps) { if (deps !== undefined && deps !== null && !Array.isArray(deps)) { // Verify deps, but only on mount to avoid extra checks. // It's unlikely their type would change as usually you define them inline. - warning$1( - false, + error( "%s received a final argument that is not an array (instead, received `%s`). When " + "specified, the final argument must be an array.", currentHookNameInDev, @@ -11105,8 +10411,7 @@ function warnOnHookMismatchInDev(currentHookName) { table += row; } - warning$1( - false, + error( "React has detected a change in the order of Hooks called by %s. " + "This will lead to bugs and errors if not fixed. " + "For more information, read the Rules of Hooks: https://fb.me/rules-of-hooks\n\n" + @@ -11140,8 +10445,7 @@ function areHookInputsEqual(nextDeps, prevDeps) { if (prevDeps === null) { { - warning$1( - false, + error( "%s received a final argument during this render, but not during " + "the previous render. Even though the final argument is optional, " + "its type cannot change between renders.", @@ -11156,8 +10460,7 @@ function areHookInputsEqual(nextDeps, prevDeps) { // Don't bother comparing lengths in prod because these arrays should be // passed inline. if (nextDeps.length !== prevDeps.length) { - warning$1( - false, + error( "The final argument passed to %s changed size between renders. The " + "order and size of this array must remain constant.\n\n" + "Previous: %s\n" + @@ -11185,12 +10488,11 @@ function renderWithHooks( workInProgress, Component, props, - refOrContext, + secondArg, nextRenderExpirationTime ) { renderExpirationTime$1 = nextRenderExpirationTime; currentlyRenderingFiber$1 = workInProgress; - nextCurrentHook = current !== null ? current.memoizedState : null; { hookTypesDev = current !== null ? current._debugHookTypes : null; @@ -11198,24 +10500,25 @@ function renderWithHooks( ignorePreviousDependencies = current !== null && current.type !== workInProgress.type; - } // The following should have already been reset + } + + workInProgress.memoizedState = null; + workInProgress.updateQueue = null; + workInProgress.expirationTime = NoWork; // The following should have already been reset // currentHook = null; // workInProgressHook = null; - // remainingExpirationTime = NoWork; - // componentUpdateQueue = null; // didScheduleRenderPhaseUpdate = false; // renderPhaseUpdates = null; // numberOfReRenders = 0; - // sideEffectTag = 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 nextCurrentHook === null. + // 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) - // Using nextCurrentHook to differentiate between mount/update only works if at least one stateful hook is used. + // Using memoizedState to differentiate between mount/update only works if at least one stateful hook is used. // Non-stateful hooks (e.g. context) don't get added to memoizedState, - // so nextCurrentHook would be null during updates and mounts. + // so memoizedState would be null during updates and mounts. { - if (nextCurrentHook !== null) { + if (current !== null && current.memoizedState !== null) { ReactCurrentDispatcher$1.current = HooksDispatcherOnUpdateInDEV; } else if (hookTypesDev !== null) { // This dispatcher handles an edge case where a component is updating, @@ -11229,7 +10532,7 @@ function renderWithHooks( } } - var children = Component(props, refOrContext); + var children = Component(props, secondArg); if (didScheduleRenderPhaseUpdate) { do { @@ -11242,11 +10545,9 @@ function renderWithHooks( ignorePreviousDependencies = false; } // Start over from the beginning of the list - nextCurrentHook = current !== null ? current.memoizedState : null; - nextWorkInProgressHook = firstWorkInProgressHook; currentHook = null; workInProgressHook = null; - componentUpdateQueue = null; + workInProgress.updateQueue = null; { // Also validate hook order for cascading updates. @@ -11254,7 +10555,7 @@ function renderWithHooks( } ReactCurrentDispatcher$1.current = HooksDispatcherOnUpdateInDEV; - children = Component(props, refOrContext); + children = Component(props, secondArg); } while (didScheduleRenderPhaseUpdate); renderPhaseUpdates = null; @@ -11263,14 +10564,9 @@ function renderWithHooks( // at the beginning of the render phase and there's no re-entrancy. ReactCurrentDispatcher$1.current = ContextOnlyDispatcher; - var renderedWork = currentlyRenderingFiber$1; - renderedWork.memoizedState = firstWorkInProgressHook; - renderedWork.expirationTime = remainingExpirationTime; - renderedWork.updateQueue = componentUpdateQueue; - renderedWork.effectTag |= sideEffectTag; { - renderedWork._debugHookTypes = hookTypesDev; + workInProgress._debugHookTypes = hookTypesDev; } // This check uses currentHook so that it works the same in DEV and prod bundles. // hookTypesDev could catch more cases (e.g. context) but only in DEV bundles. @@ -11278,20 +10574,13 @@ function renderWithHooks( renderExpirationTime$1 = NoWork; currentlyRenderingFiber$1 = null; currentHook = null; - nextCurrentHook = null; - firstWorkInProgressHook = null; workInProgressHook = null; - nextWorkInProgressHook = null; { currentHookNameInDev = null; hookTypesDev = null; hookTypesUpdateIndexDev = -1; - } - - remainingExpirationTime = NoWork; - componentUpdateQueue = null; - sideEffectTag = 0; // These were reset above + } // These were reset above // didScheduleRenderPhaseUpdate = false; // renderPhaseUpdates = null; // numberOfReRenders = 0; @@ -11322,10 +10611,7 @@ function resetHooks() { renderExpirationTime$1 = NoWork; currentlyRenderingFiber$1 = null; currentHook = null; - nextCurrentHook = null; - firstWorkInProgressHook = null; workInProgressHook = null; - nextWorkInProgressHook = null; { hookTypesDev = null; @@ -11333,9 +10619,6 @@ function resetHooks() { currentHookNameInDev = null; } - remainingExpirationTime = NoWork; - componentUpdateQueue = null; - sideEffectTag = 0; didScheduleRenderPhaseUpdate = false; renderPhaseUpdates = null; numberOfReRenders = 0; @@ -11345,14 +10628,14 @@ function mountWorkInProgressHook() { var hook = { memoizedState: null, baseState: null, + baseQueue: null, queue: null, - baseUpdate: null, next: null }; if (workInProgressHook === null) { // This is the first hook in the list - firstWorkInProgressHook = workInProgressHook = hook; + currentlyRenderingFiber$1.memoizedState = workInProgressHook = hook; } else { // Append to the end of the list workInProgressHook = workInProgressHook.next = hook; @@ -11367,12 +10650,33 @@ function updateWorkInProgressHook() { // clone, or a work-in-progress hook from a previous render pass that we can // use as a base. When we reach the end of the base list, we must switch to // the dispatcher used for mounts. + var nextCurrentHook; + + if (currentHook === null) { + var current = currentlyRenderingFiber$1.alternate; + + if (current !== null) { + nextCurrentHook = current.memoizedState; + } else { + nextCurrentHook = null; + } + } else { + nextCurrentHook = currentHook.next; + } + + var nextWorkInProgressHook; + + if (workInProgressHook === null) { + nextWorkInProgressHook = currentlyRenderingFiber$1.memoizedState; + } else { + nextWorkInProgressHook = workInProgressHook.next; + } + if (nextWorkInProgressHook !== null) { // There's already a work-in-progress. Reuse it. workInProgressHook = nextWorkInProgressHook; nextWorkInProgressHook = workInProgressHook.next; currentHook = nextCurrentHook; - nextCurrentHook = currentHook !== null ? currentHook.next : null; } else { // Clone from the current hook. if (!(nextCurrentHook !== null)) { @@ -11383,20 +10687,18 @@ function updateWorkInProgressHook() { var newHook = { memoizedState: currentHook.memoizedState, baseState: currentHook.baseState, + baseQueue: currentHook.baseQueue, queue: currentHook.queue, - baseUpdate: currentHook.baseUpdate, next: null }; if (workInProgressHook === null) { // This is the first hook in the list. - workInProgressHook = firstWorkInProgressHook = newHook; + currentlyRenderingFiber$1.memoizedState = workInProgressHook = newHook; } else { // Append to the end of the list. workInProgressHook = workInProgressHook.next = newHook; } - - nextCurrentHook = currentHook.next; } return workInProgressHook; @@ -11424,13 +10726,13 @@ function mountReducer(reducer, initialArg, init) { hook.memoizedState = hook.baseState = initialState; var queue = (hook.queue = { - last: null, + pending: null, dispatch: null, lastRenderedReducer: reducer, lastRenderedState: initialState }); var dispatch = (queue.dispatch = dispatchAction.bind( - null, // Flow doesn't know this is non-null, but we do. + null, currentlyRenderingFiber$1, queue )); @@ -11482,7 +10784,7 @@ function updateReducer(reducer, initialArg, init) { // TODO: Not sure if this is the desired semantics, but it's what we // do for gDSFP. I can't remember why. - if (hook.baseUpdate === queue.last) { + if (hook.baseQueue === null) { hook.baseState = newState; } @@ -11492,35 +10794,37 @@ function updateReducer(reducer, initialArg, init) { } return [hook.memoizedState, _dispatch]; - } // The last update in the entire queue + } - var last = queue.last; // The last update that is part of the base state. + var current = currentHook; // The last rebase update that is NOT part of the base state. - var baseUpdate = hook.baseUpdate; - var baseState = hook.baseState; // Find the first unprocessed update. + var baseQueue = current.baseQueue; // The last pending update that hasn't been processed yet. - var first; + var pendingQueue = queue.pending; - if (baseUpdate !== null) { - if (last !== null) { - // For the first update, the queue is a circular linked list where - // `queue.last.next = queue.first`. Once the first update commits, and - // the `baseUpdate` is no longer empty, we can unravel the list. - last.next = null; + if (pendingQueue !== null) { + // We have new updates that haven't been processed yet. + // We'll add them to the base queue. + if (baseQueue !== null) { + // Merge the pending queue and the base queue. + var baseFirst = baseQueue.next; + var pendingFirst = pendingQueue.next; + baseQueue.next = pendingFirst; + pendingQueue.next = baseFirst; } - first = baseUpdate.next; - } else { - first = last !== null ? last.next : null; + current.baseQueue = baseQueue = pendingQueue; + queue.pending = null; } - if (first !== null) { - var _newState = baseState; + if (baseQueue !== null) { + // We have a queue to process. + var first = baseQueue.next; + var _newState = current.baseState; var newBaseState = null; - var newBaseUpdate = null; - var prevUpdate = baseUpdate; + var newBaseQueueFirst = null; + var newBaseQueueLast = null; var _update = first; - var didSkip = false; do { var updateExpirationTime = _update.expirationTime; @@ -11529,24 +10833,46 @@ function updateReducer(reducer, initialArg, init) { // Priority is insufficient. Skip this update. If this is the first // skipped update, the previous update/state is the new base // update/state. - if (!didSkip) { - didSkip = true; - newBaseUpdate = prevUpdate; + var clone = { + expirationTime: _update.expirationTime, + suspenseConfig: _update.suspenseConfig, + action: _update.action, + eagerReducer: _update.eagerReducer, + eagerState: _update.eagerState, + next: null + }; + + if (newBaseQueueLast === null) { + newBaseQueueFirst = newBaseQueueLast = clone; newBaseState = _newState; + } else { + newBaseQueueLast = newBaseQueueLast.next = clone; } // Update the remaining priority in the queue. - if (updateExpirationTime > remainingExpirationTime) { - remainingExpirationTime = updateExpirationTime; - markUnprocessedUpdateTime(remainingExpirationTime); + if (updateExpirationTime > currentlyRenderingFiber$1.expirationTime) { + currentlyRenderingFiber$1.expirationTime = updateExpirationTime; + markUnprocessedUpdateTime(updateExpirationTime); } } else { // This update does have sufficient priority. - // Mark the event time of this update as relevant to this render pass. + if (newBaseQueueLast !== null) { + var _clone = { + expirationTime: Sync, + // This update is going to be committed so we never want uncommit it. + suspenseConfig: _update.suspenseConfig, + action: _update.action, + eagerReducer: _update.eagerReducer, + eagerState: _update.eagerState, + next: null + }; + newBaseQueueLast = newBaseQueueLast.next = _clone; + } // Mark the event time of this update as relevant to this render pass. // TODO: This should ideally use the true event time of this update rather than // its priority which is a derived and not reverseable value. // TODO: We should skip this update if it was already committed but currently // we have no way of detecting the difference between a committed and suspended // update here. + markRenderEventTimeAndConfig( updateExpirationTime, _update.suspenseConfig @@ -11562,13 +10888,13 @@ function updateReducer(reducer, initialArg, init) { } } - prevUpdate = _update; _update = _update.next; } while (_update !== null && _update !== first); - if (!didSkip) { - newBaseUpdate = prevUpdate; + if (newBaseQueueLast === null) { newBaseState = _newState; + } else { + newBaseQueueLast.next = newBaseQueueFirst; } // Mark that the fiber performed work, but only if the new state is // different from the current state. @@ -11577,8 +10903,8 @@ function updateReducer(reducer, initialArg, init) { } hook.memoizedState = _newState; - hook.baseUpdate = newBaseUpdate; hook.baseState = newBaseState; + hook.baseQueue = newBaseQueueLast; queue.lastRenderedState = _newState; } @@ -11595,13 +10921,13 @@ function mountState(initialState) { hook.memoizedState = hook.baseState = initialState; var queue = (hook.queue = { - last: null, + pending: null, dispatch: null, lastRenderedReducer: basicStateReducer, lastRenderedState: initialState }); var dispatch = (queue.dispatch = dispatchAction.bind( - null, // Flow doesn't know this is non-null, but we do. + null, currentlyRenderingFiber$1, queue )); @@ -11621,9 +10947,11 @@ function pushEffect(tag, create, destroy, deps) { // Circular next: null }; + var componentUpdateQueue = currentlyRenderingFiber$1.updateQueue; if (componentUpdateQueue === null) { componentUpdateQueue = createFunctionComponentUpdateQueue(); + currentlyRenderingFiber$1.updateQueue = componentUpdateQueue; componentUpdateQueue.lastEffect = effect.next = effect; } else { var lastEffect = componentUpdateQueue.lastEffect; @@ -11663,7 +10991,7 @@ function updateRef(initialValue) { function mountEffectImpl(fiberEffectTag, hookEffectTag, create, deps) { var hook = mountWorkInProgressHook(); var nextDeps = deps === undefined ? null : deps; - sideEffectTag |= fiberEffectTag; + currentlyRenderingFiber$1.effectTag |= fiberEffectTag; hook.memoizedState = pushEffect(hookEffectTag, create, undefined, nextDeps); } @@ -11686,7 +11014,7 @@ function updateEffectImpl(fiberEffectTag, hookEffectTag, create, deps) { } } - sideEffectTag |= fiberEffectTag; + currentlyRenderingFiber$1.effectTag |= fiberEffectTag; hook.memoizedState = pushEffect(hookEffectTag, create, destroy, nextDeps); } @@ -11744,14 +11072,13 @@ function imperativeHandleEffect(create, ref) { var refObject = ref; { - !refObject.hasOwnProperty("current") - ? warning$1( - false, - "Expected useImperativeHandle() first argument to either be a " + - "ref callback or React.createRef() object. Instead received: %s.", - "an object with keys {" + Object.keys(refObject).join(", ") + "}" - ) - : void 0; + if (!refObject.hasOwnProperty("current")) { + error( + "Expected useImperativeHandle() first argument to either be a " + + "ref callback or React.createRef() object. Instead received: %s.", + "an object with keys {" + Object.keys(refObject).join(", ") + "}" + ); + } } var _inst2 = create(); @@ -11765,14 +11092,13 @@ function imperativeHandleEffect(create, ref) { function mountImperativeHandle(ref, create, deps) { { - !(typeof create === "function") - ? warning$1( - false, - "Expected useImperativeHandle() second argument to be a function " + - "that creates a handle. Instead received: %s.", - create !== null ? typeof create : "null" - ) - : void 0; + if (typeof create !== "function") { + error( + "Expected useImperativeHandle() second argument to be a function " + + "that creates a handle. Instead received: %s.", + create !== null ? typeof create : "null" + ); + } } // TODO: If deps are provided, should we skip comparing the ref itself? var effectDeps = @@ -11787,14 +11113,13 @@ function mountImperativeHandle(ref, create, deps) { function updateImperativeHandle(ref, create, deps) { { - !(typeof create === "function") - ? warning$1( - false, - "Expected useImperativeHandle() second argument to be a function " + - "that creates a handle. Instead received: %s.", - create !== null ? typeof create : "null" - ) - : void 0; + if (typeof create !== "function") { + error( + "Expected useImperativeHandle() second argument to be a function " + + "that creates a handle. Instead received: %s.", + create !== null ? typeof create : "null" + ); + } } // TODO: If deps are provided, should we skip comparing the ref itself? var effectDeps = @@ -11877,17 +11202,14 @@ function mountDeferredValue(value, config) { mountEffect( function() { - Scheduler.unstable_next(function() { - var previousConfig = ReactCurrentBatchConfig$1.suspense; - ReactCurrentBatchConfig$1.suspense = - config === undefined ? null : config; + var previousConfig = ReactCurrentBatchConfig$1.suspense; + ReactCurrentBatchConfig$1.suspense = config === undefined ? null : config; - try { - setValue(value); - } finally { - ReactCurrentBatchConfig$1.suspense = previousConfig; - } - }); + try { + setValue(value); + } finally { + ReactCurrentBatchConfig$1.suspense = previousConfig; + } }, [value, config] ); @@ -11901,47 +11223,54 @@ function updateDeferredValue(value, config) { updateEffect( function() { - Scheduler.unstable_next(function() { - var previousConfig = ReactCurrentBatchConfig$1.suspense; - ReactCurrentBatchConfig$1.suspense = - config === undefined ? null : config; + var previousConfig = ReactCurrentBatchConfig$1.suspense; + ReactCurrentBatchConfig$1.suspense = config === undefined ? null : config; - try { - setValue(value); - } finally { - ReactCurrentBatchConfig$1.suspense = previousConfig; - } - }); + try { + setValue(value); + } finally { + ReactCurrentBatchConfig$1.suspense = previousConfig; + } }, [value, config] ); return prevValue; } +function startTransition(setPending, config, callback) { + var priorityLevel = getCurrentPriorityLevel(); + runWithPriority( + priorityLevel < UserBlockingPriority ? UserBlockingPriority : priorityLevel, + function() { + setPending(true); + } + ); + runWithPriority( + priorityLevel > NormalPriority ? NormalPriority : priorityLevel, + function() { + var previousConfig = ReactCurrentBatchConfig$1.suspense; + ReactCurrentBatchConfig$1.suspense = config === undefined ? null : config; + + try { + setPending(false); + callback(); + } finally { + ReactCurrentBatchConfig$1.suspense = previousConfig; + } + } + ); +} + function mountTransition(config) { var _mountState2 = mountState(false), isPending = _mountState2[0], setPending = _mountState2[1]; - var startTransition = mountCallback( - function(callback) { - setPending(true); - Scheduler.unstable_next(function() { - var previousConfig = ReactCurrentBatchConfig$1.suspense; - ReactCurrentBatchConfig$1.suspense = - config === undefined ? null : config; - - try { - setPending(false); - callback(); - } finally { - ReactCurrentBatchConfig$1.suspense = previousConfig; - } - }); - }, - [config, isPending] - ); - return [startTransition, isPending]; + var start = mountCallback(startTransition.bind(null, setPending, config), [ + setPending, + config + ]); + return [start, isPending]; } function updateTransition(config) { @@ -11949,25 +11278,11 @@ function updateTransition(config) { isPending = _updateState2[0], setPending = _updateState2[1]; - var startTransition = updateCallback( - function(callback) { - setPending(true); - Scheduler.unstable_next(function() { - var previousConfig = ReactCurrentBatchConfig$1.suspense; - ReactCurrentBatchConfig$1.suspense = - config === undefined ? null : config; - - try { - setPending(false); - callback(); - } finally { - ReactCurrentBatchConfig$1.suspense = previousConfig; - } - }); - }, - [config, isPending] - ); - return [startTransition, isPending]; + var start = updateCallback(startTransition.bind(null, setPending, config), [ + setPending, + config + ]); + return [start, isPending]; } function dispatchAction(fiber, queue, action) { @@ -11978,14 +11293,13 @@ function dispatchAction(fiber, queue, action) { } { - !(typeof arguments[3] !== "function") - ? warning$1( - false, - "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()." - ) - : void 0; + 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()." + ); + } } var alternate = fiber.alternate; @@ -12050,23 +11364,17 @@ function dispatchAction(fiber, queue, action) { _update2.priority = getCurrentPriorityLevel(); } // Append the update to the end of the list. - var last = queue.last; + var pending = queue.pending; - if (last === null) { + if (pending === null) { // This is the first update. Create a circular list. _update2.next = _update2; } else { - var first = last.next; - - if (first !== null) { - // Still circular. - _update2.next = first; - } - - last.next = _update2; + _update2.next = pending.next; + pending.next = _update2; } - queue.last = _update2; + queue.pending = _update2; if ( fiber.expirationTime === NoWork && @@ -12102,7 +11410,7 @@ function dispatchAction(fiber, queue, action) { // time the reducer has changed. return; } - } catch (error) { + } catch (error$$1) { // Suppress the error. It will throw again in the render phase. } finally { { @@ -12148,8 +11456,7 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null; { var warnInvalidContextAccess = function() { - warning$1( - false, + 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 " + @@ -12158,8 +11465,7 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null; }; var warnInvalidHookAccess = function() { - warning$1( - false, + error( "Do not call Hooks inside useEffect(...), useMemo(...), or other built-in Hooks. " + "You can only call Hooks at the top level of your React function. " + "For more information, see " + @@ -12250,7 +11556,7 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null; useResponder: function(responder, props) { currentHookNameInDev = "useResponder"; mountHookTypesDev(); - return createResponderListener(responder, props); + return createDeprecatedResponderListener(responder, props); }, useDeferredValue: function(value, config) { currentHookNameInDev = "useDeferredValue"; @@ -12341,7 +11647,7 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null; useResponder: function(responder, props) { currentHookNameInDev = "useResponder"; updateHookTypesDev(); - return createResponderListener(responder, props); + return createDeprecatedResponderListener(responder, props); }, useDeferredValue: function(value, config) { currentHookNameInDev = "useDeferredValue"; @@ -12432,7 +11738,7 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null; useResponder: function(responder, props) { currentHookNameInDev = "useResponder"; updateHookTypesDev(); - return createResponderListener(responder, props); + return createDeprecatedResponderListener(responder, props); }, useDeferredValue: function(value, config) { currentHookNameInDev = "useDeferredValue"; @@ -12535,7 +11841,7 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null; currentHookNameInDev = "useResponder"; warnInvalidHookAccess(); mountHookTypesDev(); - return createResponderListener(responder, props); + return createDeprecatedResponderListener(responder, props); }, useDeferredValue: function(value, config) { currentHookNameInDev = "useDeferredValue"; @@ -12640,7 +11946,7 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null; currentHookNameInDev = "useResponder"; warnInvalidHookAccess(); updateHookTypesDev(); - return createResponderListener(responder, props); + return createDeprecatedResponderListener(responder, props); }, useDeferredValue: function(value, config) { currentHookNameInDev = "useDeferredValue"; @@ -12720,12 +12026,11 @@ var isHydrating = false; function warnIfHydrating() { { - !!isHydrating - ? warning$1( - false, - "We should not be hydrating here. This is a bug in React. Please file a bug." - ) - : void 0; + if (isHydrating) { + error( + "We should not be hydrating here. This is a bug in React. Please file a bug." + ); + } } } @@ -13252,8 +12557,8 @@ function forceUnmountCurrentAndReconcile( renderExpirationTime ); // 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 their - // identity matches. + // the effect of remounting all children regardless of whether their + // identities match. workInProgress.child = reconcileChildFibers( workInProgress, @@ -13513,7 +12818,7 @@ function updateSimpleMemoComponent( if ( shallowEqual(prevProps, nextProps) && - current$$1.ref === workInProgress.ref && // Prevent bailout if the implementation changed due to hot reload: + current$$1.ref === workInProgress.ref && // Prevent bailout if the implementation changed due to hot reload. workInProgress.type === current$$1.type ) { didReceiveUpdate = false; @@ -13673,6 +12978,73 @@ function updateFunctionComponent( return workInProgress.child; } +function updateChunk( + current$$1, + workInProgress, + chunk, + nextProps, + renderExpirationTime +) { + // 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. + var render = chunk.render; + var data = chunk.query(); // The rest is a fork of updateFunctionComponent + + var nextChildren; + prepareToReadContext(workInProgress, renderExpirationTime); + + { + ReactCurrentOwner$3.current = workInProgress; + setCurrentPhase("render"); + nextChildren = renderWithHooks( + current$$1, + workInProgress, + render, + nextProps, + data, + renderExpirationTime + ); + + if ( + debugRenderPhaseSideEffectsForStrictMode && + workInProgress.mode & StrictMode + ) { + // Only double-render components with Hooks + if (workInProgress.memoizedState !== null) { + nextChildren = renderWithHooks( + current$$1, + workInProgress, + render, + nextProps, + data, + renderExpirationTime + ); + } + } + + setCurrentPhase(null); + } + + if (current$$1 !== null && !didReceiveUpdate) { + bailoutHooks(current$$1, workInProgress, renderExpirationTime); + return bailoutOnAlreadyFinishedWork( + current$$1, + workInProgress, + renderExpirationTime + ); + } // React DevTools reads this flag. + + workInProgress.effectTag |= PerformedWork; + reconcileChildren( + current$$1, + workInProgress, + nextChildren, + renderExpirationTime + ); + return workInProgress.child; +} + function updateClassComponent( current$$1, workInProgress, @@ -13715,9 +13087,9 @@ function updateClassComponent( if (instance === null) { if (current$$1 !== null) { - // An class component without an instance only mounts if it suspended - // inside a non- concurrent tree, in an inconsistent state. We want to - // tree it like a new mount, even though an empty version of it already + // 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$$1.alternate = null; workInProgress.alternate = null; // Since this is conceptually a new fiber, schedule a Placement effect @@ -13769,14 +13141,14 @@ function updateClassComponent( var inst = workInProgress.stateNode; if (inst.props !== nextProps) { - !didWarnAboutReassigningProps - ? warning$1( - false, - "It looks like %s is reassigning its own `this.props` while rendering. " + - "This is not supported and can lead to confusing bugs.", - getComponentName(workInProgress.type) || "a component" - ) - : void 0; + 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.", + getComponentName(workInProgress.type) || "a component" + ); + } + didWarnAboutReassigningProps = true; } } @@ -13818,7 +13190,7 @@ function finishClassComponent( didCaptureError && typeof Component.getDerivedStateFromError !== "function" ) { - // If we captured an error, but getDerivedStateFrom catch is not defined, + // 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. @@ -13897,7 +13269,7 @@ function updateHostRoot(current$$1, workInProgress, renderExpirationTime) { pushHostRootContext(workInProgress); var updateQueue = workInProgress.updateQueue; - if (!(updateQueue !== null)) { + if (!(current$$1 !== 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." ); @@ -13906,13 +13278,8 @@ function updateHostRoot(current$$1, workInProgress, renderExpirationTime) { var nextProps = workInProgress.pendingProps; var prevState = workInProgress.memoizedState; var prevChildren = prevState !== null ? prevState.element : null; - processUpdateQueue( - workInProgress, - updateQueue, - nextProps, - null, - renderExpirationTime - ); + cloneUpdateQueue(current$$1, workInProgress); + processUpdateQueue(workInProgress, nextProps, null, renderExpirationTime); var nextState = workInProgress.memoizedState; // Caution: React DevTools currently depends on this property // being called "element". @@ -13986,7 +13353,7 @@ function updateHostComponent(current$$1, workInProgress, renderExpirationTime) { if (isDirectTextChild) { // We special case a direct text child of a host node. This is a common // case. We won't handle it as a reified child. We will instead handle - // this in the host environment that also have access to this prop. That + // this in the host environment that also has access to this prop. That // avoids allocating another HostText fiber and traversing it. nextChildren = null; } else if (prevProps !== null && shouldSetTextContent(type, prevProps)) { @@ -14036,7 +13403,7 @@ function mountLazyComponent( renderExpirationTime ) { if (_current !== null) { - // An lazy component only mounts if it suspended inside a non- + // 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. @@ -14074,7 +13441,7 @@ function mountLazyComponent( resolvedProps, renderExpirationTime ); - break; + return child; } case ClassComponent: { @@ -14091,7 +13458,7 @@ function mountLazyComponent( resolvedProps, renderExpirationTime ); - break; + return child; } case ForwardRef: { @@ -14108,7 +13475,7 @@ function mountLazyComponent( resolvedProps, renderExpirationTime ); - break; + return child; } case MemoComponent: { @@ -14136,36 +13503,48 @@ function mountLazyComponent( updateExpirationTime, renderExpirationTime ); - break; + return child; } - default: { - 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 Error( - "Element type is invalid. Received a promise that resolves to: " + - Component + - ". Lazy element type must resolve to a class or function." + - hint + case Chunk: { + if (enableChunksAPI) { + // TODO: Resolve for Hot Reloading. + child = updateChunk( + null, + workInProgress, + Component, + props, + renderExpirationTime ); + return child; } + + break; } } - 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 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( @@ -14259,13 +13638,13 @@ function mountIndeterminateComponent( var componentName = getComponentName(Component) || "Unknown"; if (!didWarnAboutBadClass[componentName]) { - warningWithoutStack$1( - false, + 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 ); + didWarnAboutBadClass[componentName] = true; } } @@ -14297,8 +13676,7 @@ function mountIndeterminateComponent( var _componentName = getComponentName(Component) || "Unknown"; if (!didWarnAboutModulePatternComponent[_componentName]) { - warningWithoutStack$1( - false, + 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. " + @@ -14308,6 +13686,7 @@ function mountIndeterminateComponent( _componentName, _componentName ); + didWarnAboutModulePatternComponent[_componentName] = true; } } // Proceed under the assumption that this is a class instance @@ -14329,6 +13708,7 @@ function mountIndeterminateComponent( workInProgress.memoizedState = value.state !== null && value.state !== undefined ? value.state : null; + initializeUpdateQueue(workInProgress); var getDerivedStateFromProps = Component.getDerivedStateFromProps; if (typeof getDerivedStateFromProps === "function") { @@ -14356,8 +13736,7 @@ function mountIndeterminateComponent( { if (disableLegacyContext && Component.contextTypes) { - warningWithoutStack$1( - false, + error( "%s uses the legacy contextTypes API which is no longer supported. " + "Use React.createContext() with React.useContext() instead.", getComponentName(Component) || "Unknown" @@ -14393,86 +13772,87 @@ function mountIndeterminateComponent( } function validateFunctionComponentInDev(workInProgress, Component) { - if (Component) { - !!Component.childContextTypes - ? warningWithoutStack$1( - false, + { + if (Component) { + if (Component.childContextTypes) { + error( "%s(...): childContextTypes cannot be defined on a function component.", Component.displayName || Component.name || "Component" - ) - : void 0; - } + ); + } + } - if (workInProgress.ref !== null) { - var info = ""; - var ownerName = getCurrentFiberOwnerNameInDevOrNull(); + if (workInProgress.ref !== null) { + var info = ""; + var ownerName = getCurrentFiberOwnerNameInDevOrNull(); - if (ownerName) { - info += "\n\nCheck the render method of `" + ownerName + "`."; - } + if (ownerName) { + info += "\n\nCheck the render method of `" + ownerName + "`."; + } - var warningKey = ownerName || workInProgress._debugID || ""; - var debugSource = workInProgress._debugSource; + var warningKey = ownerName || workInProgress._debugID || ""; + var debugSource = workInProgress._debugSource; - if (debugSource) { - warningKey = debugSource.fileName + ":" + debugSource.lineNumber; - } + if (debugSource) { + warningKey = debugSource.fileName + ":" + debugSource.lineNumber; + } - if (!didWarnAboutFunctionRefs[warningKey]) { - didWarnAboutFunctionRefs[warningKey] = true; - warning$1( - false, - "Function components cannot be given refs. " + - "Attempts to access this ref will fail. " + - "Did you mean to use React.forwardRef()?%s", - info - ); + 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 + ); + } } - } - if ( - warnAboutDefaultPropsOnFunctionComponents && - Component.defaultProps !== undefined - ) { - var componentName = getComponentName(Component) || "Unknown"; - - if (!didWarnAboutDefaultPropsOnFunctionComponent[componentName]) { - warningWithoutStack$1( - false, - "%s: Support for defaultProps will be removed from function components " + - "in a future major release. Use JavaScript default parameters instead.", - componentName - ); - didWarnAboutDefaultPropsOnFunctionComponent[componentName] = true; + if ( + warnAboutDefaultPropsOnFunctionComponents && + Component.defaultProps !== undefined + ) { + var componentName = getComponentName(Component) || "Unknown"; + + if (!didWarnAboutDefaultPropsOnFunctionComponent[componentName]) { + error( + "%s: Support for defaultProps will be removed from function components " + + "in a future major release. Use JavaScript default parameters instead.", + componentName + ); + + didWarnAboutDefaultPropsOnFunctionComponent[componentName] = true; + } } - } - if (typeof Component.getDerivedStateFromProps === "function") { - var _componentName2 = getComponentName(Component) || "Unknown"; + if (typeof Component.getDerivedStateFromProps === "function") { + var _componentName2 = getComponentName(Component) || "Unknown"; - if (!didWarnAboutGetDerivedStateOnFunctionComponent[_componentName2]) { - warningWithoutStack$1( - false, - "%s: Function components do not support getDerivedStateFromProps.", - _componentName2 - ); - didWarnAboutGetDerivedStateOnFunctionComponent[_componentName2] = true; + if (!didWarnAboutGetDerivedStateOnFunctionComponent[_componentName2]) { + error( + "%s: Function components do not support getDerivedStateFromProps.", + _componentName2 + ); + + didWarnAboutGetDerivedStateOnFunctionComponent[_componentName2] = true; + } } - } - if ( - typeof Component.contextType === "object" && - Component.contextType !== null - ) { - var _componentName3 = getComponentName(Component) || "Unknown"; + if ( + typeof Component.contextType === "object" && + Component.contextType !== null + ) { + var _componentName3 = getComponentName(Component) || "Unknown"; - if (!didWarnAboutContextTypeOnFunctionComponent[_componentName3]) { - warningWithoutStack$1( - false, - "%s: Function components do not support contextType.", - _componentName3 - ); - didWarnAboutContextTypeOnFunctionComponent[_componentName3] = true; + if (!didWarnAboutContextTypeOnFunctionComponent[_componentName3]) { + error( + "%s: Function components do not support contextType.", + _componentName3 + ); + + didWarnAboutContextTypeOnFunctionComponent[_componentName3] = true; + } } } } @@ -14544,8 +13924,8 @@ function updateSuspenseComponent( if ("maxDuration" in nextProps) { if (!didWarnAboutMaxDuration) { didWarnAboutMaxDuration = true; - warning$1( - false, + + error( "maxDuration has been removed from React. " + "Remove the maxDuration prop." ); @@ -14917,7 +14297,7 @@ function updateSuspenseComponent( workInProgress.child = _primaryChildFragment3; return _fallbackChildFragment3; } else { - // Still haven't timed out. Continue rendering the children, like we + // Still haven't timed out. Continue rendering the children, like we // normally do. workInProgress.memoizedState = null; var _nextPrimaryChildren2 = nextProps.children; @@ -14963,8 +14343,7 @@ function mountDehydratedSuspenseComponent( // Instead, we'll leave the content in place and try to hydrate it later. if ((workInProgress.mode & BlockingMode) === NoMode) { { - warning$1( - false, + error( "Cannot hydrate Suspense in legacy mode. Switch from " + "ReactDOM.hydrate(element, container) to " + "ReactDOM.createBlockingRoot(container, { hydrate: true })" + @@ -15224,40 +14603,39 @@ function validateRevealOrder(revealOrder) { case "together": case "forwards": case "backwards": { - warning$1( - false, + error( '"%s" is not a valid value for revealOrder on . ' + 'Use lowercase "%s" instead.', revealOrder, revealOrder.toLowerCase() ); + break; } case "forward": case "backward": { - warning$1( - false, + 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: - warning$1( - false, + error( '"%s" is not a supported revealOrder on . ' + 'Did you mean "together", "forwards" or "backwards"?', revealOrder ); + break; } } else { - warning$1( - false, + error( "%s is not a supported value for revealOrder on . " + 'Did you mean "together", "forwards" or "backwards"?', revealOrder @@ -15272,16 +14650,16 @@ function validateTailOptions(tailMode, revealOrder) { if (tailMode !== undefined && !didWarnAboutTailOptions[tailMode]) { if (tailMode !== "collapsed" && tailMode !== "hidden") { didWarnAboutTailOptions[tailMode] = true; - warning$1( - false, + + 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; - warning$1( - false, + + error( ' is only valid if revealOrder is ' + '"forwards" or "backwards". ' + 'Did you mean to specify revealOrder="forwards"?', @@ -15299,8 +14677,8 @@ function validateSuspenseListNestedChild(childSlot, index) { if (isArray || isIterable) { var type = isArray ? "array" : "iterable"; - warning$1( - false, + + error( "A nested %s was passed to row #%s in . Wrap it in " + "an additional SuspenseList to configure its revealOrder: " + " ... " + @@ -15310,6 +14688,7 @@ function validateSuspenseListNestedChild(childSlot, index) { index, type ); + return false; } } @@ -15350,8 +14729,7 @@ function validateSuspenseListChildren(children, revealOrder) { } } } else { - warning$1( - false, + 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?", @@ -15377,6 +14755,7 @@ function initSuspenseListRenderState( workInProgress.memoizedState = { isBackwards: isBackwards, rendering: null, + renderingStartTime: 0, last: lastContentRow, tail: tail, tailExpiration: 0, @@ -15387,6 +14766,7 @@ function initSuspenseListRenderState( // 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.tailExpiration = 0; @@ -15659,8 +15039,8 @@ function updateContextConsumer( if (context !== context.Consumer) { if (!hasWarnedAboutUsingContextAsConsumer) { hasWarnedAboutUsingContextAsConsumer = true; - warning$1( - false, + + error( "Rendering directly is not supported and will be removed in " + "a future major release. Did you mean to render instead?" ); @@ -15675,15 +15055,14 @@ function updateContextConsumer( var render = newProps.children; { - !(typeof render === "function") - ? warningWithoutStack$1( - false, - "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." - ) - : void 0; + 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." + ); + } } prepareToReadContext(workInProgress, renderExpirationTime); @@ -16291,6 +15670,22 @@ function beginWork$1(current$$1, workInProgress, renderExpirationTime) { break; } + + case Chunk: { + if (enableChunksAPI) { + var chunk = workInProgress.type; + var props = workInProgress.pendingProps; + return updateChunk( + current$$1, + workInProgress, + chunk, + props, + renderExpirationTime + ); + } + + break; + } } { @@ -16975,6 +16370,8 @@ if (supportsMutation) { // This lets the parents know that at least one of their children has changed. markUpdate(workInProgress); + } else { + workInProgress.stateNode = current.stateNode; } }; } else { @@ -17073,14 +16470,16 @@ function completeWork(current, workInProgress, renderExpirationTime) { switch (workInProgress.tag) { case IndeterminateComponent: - break; - case LazyComponent: - break; - case SimpleMemoComponent: case FunctionComponent: - break; + case ForwardRef: + case Fragment: + case Mode: + case Profiler: + case ContextConsumer: + case MemoComponent: + return null; case ClassComponent: { var Component = workInProgress.type; @@ -17089,7 +16488,7 @@ function completeWork(current, workInProgress, renderExpirationTime) { popContext(workInProgress); } - break; + return null; } case HostRoot: { @@ -17115,7 +16514,7 @@ function completeWork(current, workInProgress, renderExpirationTime) { } updateHostContainer(workInProgress); - break; + return null; } case HostComponent: { @@ -17132,9 +16531,9 @@ function completeWork(current, workInProgress, renderExpirationTime) { rootContainerInstance ); - if (enableFlareAPI) { - var prevListeners = current.memoizedProps.listeners; - var nextListeners = newProps.listeners; + if (enableDeprecatedFlareAPI) { + var prevListeners = current.memoizedProps.DEPRECATED_flareListeners; + var nextListeners = newProps.DEPRECATED_flareListeners; if (prevListeners !== nextListeners) { markUpdate(workInProgress); @@ -17152,12 +16551,12 @@ function completeWork(current, workInProgress, renderExpirationTime) { ); } // This can happen when we abort work. - break; + return null; } 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 we want to add then top->down or + // or completeWork depending on whether we want to add them top->down or // bottom->up. Top->down is faster in IE11. var _wasHydrated = popHydrationState(workInProgress); @@ -17172,16 +16571,16 @@ function completeWork(current, workInProgress, renderExpirationTime) { currentHostContext ) ) { - // If changes to the hydrated node needs to be applied at the + // If changes to the hydrated node need to be applied at the // commit-phase we mark this as such. markUpdate(workInProgress); } - if (enableFlareAPI) { - var listeners = newProps.listeners; + if (enableDeprecatedFlareAPI) { + var listeners = newProps.DEPRECATED_flareListeners; if (listeners != null) { - updateEventListeners( + updateDeprecatedEventListeners( listeners, workInProgress, rootContainerInstance @@ -17200,11 +16599,11 @@ function completeWork(current, workInProgress, renderExpirationTime) { workInProgress.stateNode = instance; - if (enableFlareAPI) { - var _listeners = newProps.listeners; + if (enableDeprecatedFlareAPI) { + var _listeners = newProps.DEPRECATED_flareListeners; if (_listeners != null) { - updateEventListeners( + updateDeprecatedEventListeners( _listeners, workInProgress, rootContainerInstance @@ -17233,7 +16632,7 @@ function completeWork(current, workInProgress, renderExpirationTime) { } } - break; + return null; } case HostText: { @@ -17273,12 +16672,9 @@ function completeWork(current, workInProgress, renderExpirationTime) { } } - break; + return null; } - case ForwardRef: - break; - case SuspenseComponent: { popSuspenseContext(workInProgress); var nextState = workInProgress.memoizedState; @@ -17304,15 +16700,14 @@ function completeWork(current, workInProgress, renderExpirationTime) { } else { // We should never have been in a hydration state if we didn't have a current. // However, in some of those paths, we might have reentered a hydration state - // and then we might be inside a hydration state. In that case, we'll need to - // exit out of it. + // and then we might be inside a hydration state. In that case, we'll need to exit out of it. resetHydrationState(); if ((workInProgress.effectTag & DidCapture) === NoEffect) { // This boundary did not suspend so it's now hydrated and unsuspended. workInProgress.memoizedState = null; } // If nothing suspended, we need to schedule an effect to mark this boundary - // as having hydrated so events know that they're free be invoked. + // as having hydrated so events know that they're free to be invoked. // It's also a signal to replay events and the suspense callback. // If something suspended, schedule an effect to attach retry listeners. // So we might as well always mark this. @@ -17405,7 +16800,7 @@ function completeWork(current, workInProgress, renderExpirationTime) { // 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 proimse. This flag is also used to hide the + // retry listener to the promise. This flag is also used to hide the // primary children. workInProgress.effectTag |= Update; } @@ -17415,9 +16810,9 @@ function completeWork(current, workInProgress, renderExpirationTime) { // 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 proimse. This flag is also used to hide the + // 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 the + // *unhide* children that were previously hidden, so check if this // is currently timed out, too. workInProgress.effectTag |= Update; } @@ -17432,33 +16827,18 @@ function completeWork(current, workInProgress, renderExpirationTime) { workInProgress.effectTag |= Update; } - break; + return null; } - case Fragment: - break; - - case Mode: - break; - - case Profiler: - break; - case HostPortal: popHostContainer(workInProgress); updateHostContainer(workInProgress); - break; + return null; case ContextProvider: // Pop provider fiber popProvider(workInProgress); - break; - - case ContextConsumer: - break; - - case MemoComponent: - break; + return null; case IncompleteClassComponent: { // Same as class component case. I put it down here so that the tags are @@ -17469,7 +16849,7 @@ function completeWork(current, workInProgress, renderExpirationTime) { popContext(workInProgress); } - break; + return null; } case SuspenseListComponent: { @@ -17477,9 +16857,9 @@ function completeWork(current, workInProgress, renderExpirationTime) { var renderState = workInProgress.memoizedState; if (renderState === null) { - // We're running in the default, "independent" mode. We don't do anything - // in this mode. - break; + // We're running in the default, "independent" mode. + // We don't do anything in this mode. + return null; } var didSuspendAlready = @@ -17595,7 +16975,10 @@ function completeWork(current, workInProgress, renderExpirationTime) { return null; } } else if ( - now() > renderState.tailExpiration && + // The time it took to render last row is greater than time until + // the expiration. + now() * 2 - renderState.renderingStartTime > + renderState.tailExpiration && renderExpirationTime > Never ) { // We have now passed our CPU deadline and we'll just give up further @@ -17645,13 +17028,19 @@ function completeWork(current, workInProgress, renderExpirationTime) { // Heuristic for how long we're willing to spend rendering rows // until we just give up and show what we have so far. var TAIL_EXPIRATION_TIMEOUT_MS = 500; - renderState.tailExpiration = now() + TAIL_EXPIRATION_TIMEOUT_MS; + renderState.tailExpiration = now() + TAIL_EXPIRATION_TIMEOUT_MS; // TODO: This is meant to mimic the train model or JND but this + // is a per component value. It should really be since the start + // of the total render or last commit. Consider using something like + // globalMostRecentFallbackTime. That doesn't account for being + // suspended for part of the time or when it's a new render. + // It should probably use a global start time value instead. } // Pop a row. var next = renderState.tail; renderState.rendering = next; renderState.tail = next.sibling; renderState.lastEffect = workInProgress.lastEffect; + 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. @@ -17672,7 +17061,7 @@ function completeWork(current, workInProgress, renderExpirationTime) { return next; } - break; + return null; } case FundamentalComponent: { @@ -17727,6 +17116,8 @@ function completeWork(current, workInProgress, renderExpirationTime) { markUpdate(workInProgress); } } + + return null; } break; @@ -17743,13 +17134,13 @@ function completeWork(current, workInProgress, renderExpirationTime) { workInProgress.stateNode = scopeInstance; scopeInstance.methods = createScopeMethods(_type3, scopeInstance); - if (enableFlareAPI) { - var _listeners2 = newProps.listeners; + if (enableDeprecatedFlareAPI) { + var _listeners2 = newProps.DEPRECATED_flareListeners; if (_listeners2 != null) { var _rootContainerInstance2 = getRootHostContainer(); - updateEventListeners( + updateDeprecatedEventListeners( _listeners2, workInProgress, _rootContainerInstance2 @@ -17762,9 +17153,10 @@ function completeWork(current, workInProgress, renderExpirationTime) { markUpdate(workInProgress); } } else { - if (enableFlareAPI) { - var _prevListeners = current.memoizedProps.listeners; - var _nextListeners = newProps.listeners; + if (enableDeprecatedFlareAPI) { + var _prevListeners = + current.memoizedProps.DEPRECATED_flareListeners; + var _nextListeners = newProps.DEPRECATED_flareListeners; if ( _prevListeners !== _nextListeners || @@ -17782,21 +17174,28 @@ function completeWork(current, workInProgress, renderExpirationTime) { markRef$1(workInProgress); } } + + return null; } break; } - default: { - throw Error( - "Unknown unit of work tag (" + - workInProgress.tag + - "). This error is likely caused by a bug in React. Please file an issue." - ); - } + case Chunk: + if (enableChunksAPI) { + return null; + } + + break; } - 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." + ); + } } function unwindWork(workInProgress, renderExpirationTime) { @@ -17989,7 +17388,8 @@ function logCapturedError(capturedError) { // However, the browser would have silenced the original error // so we'll print it first, and then print the stack addendum. - console.error(error); // For a more detailed description of this block, see: + console["error"](error); // Don't transform to our wrapper + // For a more detailed description of this block, see: // https://github.com/facebook/react/pull/13384 } @@ -18026,7 +17426,7 @@ function logCapturedError(capturedError) { // has already printed it. Even if the application swallows the error, it is still // displayed by the browser thanks to the DEV-only fake event trick in ReactErrorUtils. - console.error(combinedMessage); + console["error"](combinedMessage); // Don't transform to our wrapper } } @@ -18124,8 +17524,8 @@ function safelyCallDestroy(current$$1, destroy) { invokeGuardedCallback(null, destroy, null); if (hasCaughtError()) { - var error = clearCaughtError(); - captureCommitPhaseError(current$$1, error); + var error$$1 = clearCaughtError(); + captureCommitPhaseError(current$$1, error$$1); } } } @@ -18134,7 +17534,8 @@ function commitBeforeMutationLifeCycles(current$$1, finishedWork) { switch (finishedWork.tag) { case FunctionComponent: case ForwardRef: - case SimpleMemoComponent: { + case SimpleMemoComponent: + case Chunk: { commitHookEffectList(UnmountSnapshot, NoEffect$1, finishedWork); return; } @@ -18154,28 +17555,27 @@ function commitBeforeMutationLifeCycles(current$$1, finishedWork) { finishedWork.type === finishedWork.elementType && !didWarnAboutReassigningProps ) { - !(instance.props === finishedWork.memoizedProps) - ? warning$1( - false, - "Expected %s props to match memoized props before " + - "getSnapshotBeforeUpdate. " + - "This might either be because of a bug in React, or because " + - "a component reassigns its own `this.props`. " + - "Please file an issue.", - getComponentName(finishedWork.type) || "instance" - ) - : void 0; - !(instance.state === finishedWork.memoizedState) - ? warning$1( - false, - "Expected %s state to match memoized state before " + - "getSnapshotBeforeUpdate. " + - "This might either be because of a bug in React, or because " + - "a component reassigns its own `this.props`. " + - "Please file an issue.", - getComponentName(finishedWork.type) || "instance" - ) - : void 0; + if (instance.props !== finishedWork.memoizedProps) { + error( + "Expected %s props to match memoized props before " + + "getSnapshotBeforeUpdate. " + + "This might either be because of a bug in React, or because " + + "a component reassigns its own `this.props`. " + + "Please file an issue.", + getComponentName(finishedWork.type) || "instance" + ); + } + + if (instance.state !== finishedWork.memoizedState) { + error( + "Expected %s state to match memoized state before " + + "getSnapshotBeforeUpdate. " + + "This might either be because of a bug in React, or because " + + "a component reassigns its own `this.props`. " + + "Please file an issue.", + getComponentName(finishedWork.type) || "instance" + ); + } } } @@ -18191,8 +17591,8 @@ function commitBeforeMutationLifeCycles(current$$1, finishedWork) { if (snapshot === undefined && !didWarnSet.has(finishedWork.type)) { didWarnSet.add(finishedWork.type); - warningWithoutStack$1( - false, + + error( "%s.getSnapshotBeforeUpdate(): A snapshot value (or null) " + "must be returned. You have returned undefined.", getComponentName(finishedWork.type) @@ -18215,14 +17615,12 @@ function commitBeforeMutationLifeCycles(current$$1, finishedWork) { case IncompleteClassComponent: // Nothing to do for these component types return; + } - 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 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." + ); } } @@ -18278,8 +17676,7 @@ function commitHookEffectList(unmountTag, mountTag, finishedWork) { addendum = " You returned: " + _destroy; } - warningWithoutStack$1( - false, + error( "An effect function must not return anything besides a function, " + "which is used for clean-up.%s%s", addendum, @@ -18299,7 +17696,8 @@ function commitPassiveHookEffects(finishedWork) { switch (finishedWork.tag) { case FunctionComponent: case ForwardRef: - case SimpleMemoComponent: { + case SimpleMemoComponent: + case Chunk: { commitHookEffectList(UnmountPassive, NoEffect$1, finishedWork); commitHookEffectList(NoEffect$1, MountPassive, finishedWork); break; @@ -18320,9 +17718,10 @@ function commitLifeCycles( switch (finishedWork.tag) { case FunctionComponent: case ForwardRef: - case SimpleMemoComponent: { + case SimpleMemoComponent: + case Chunk: { commitHookEffectList(UnmountLayout, MountLayout, finishedWork); - break; + return; } case ClassComponent: { @@ -18339,28 +17738,27 @@ function commitLifeCycles( finishedWork.type === finishedWork.elementType && !didWarnAboutReassigningProps ) { - !(instance.props === finishedWork.memoizedProps) - ? warning$1( - false, - "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.", - getComponentName(finishedWork.type) || "instance" - ) - : void 0; - !(instance.state === finishedWork.memoizedState) - ? warning$1( - false, - "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.props`. " + - "Please file an issue.", - getComponentName(finishedWork.type) || "instance" - ) - : void 0; + 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.", + getComponentName(finishedWork.type) || "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.props`. " + + "Please file an issue.", + getComponentName(finishedWork.type) || "instance" + ); + } } } @@ -18384,28 +17782,27 @@ function commitLifeCycles( finishedWork.type === finishedWork.elementType && !didWarnAboutReassigningProps ) { - !(instance.props === finishedWork.memoizedProps) - ? warning$1( - false, - "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.", - getComponentName(finishedWork.type) || "instance" - ) - : void 0; - !(instance.state === finishedWork.memoizedState) - ? warning$1( - false, - "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.props`. " + - "Please file an issue.", - getComponentName(finishedWork.type) || "instance" - ) - : void 0; + 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.", + getComponentName(finishedWork.type) || "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.props`. " + + "Please file an issue.", + getComponentName(finishedWork.type) || "instance" + ); + } } } @@ -18426,28 +17823,27 @@ function commitLifeCycles( finishedWork.type === finishedWork.elementType && !didWarnAboutReassigningProps ) { - !(instance.props === finishedWork.memoizedProps) - ? warning$1( - false, - "Expected %s props to match memoized props before " + - "processing the update queue. " + - "This might either be because of a bug in React, or because " + - "a component reassigns its own `this.props`. " + - "Please file an issue.", - getComponentName(finishedWork.type) || "instance" - ) - : void 0; - !(instance.state === finishedWork.memoizedState) - ? warning$1( - false, - "Expected %s state to match memoized state before " + - "processing the update queue. " + - "This might either be because of a bug in React, or because " + - "a component reassigns its own `this.props`. " + - "Please file an issue.", - getComponentName(finishedWork.type) || "instance" - ) - : void 0; + if (instance.props !== finishedWork.memoizedProps) { + error( + "Expected %s props to match memoized props before " + + "processing the update queue. " + + "This might either be because of a bug in React, or because " + + "a component reassigns its own `this.props`. " + + "Please file an issue.", + getComponentName(finishedWork.type) || "instance" + ); + } + + if (instance.state !== finishedWork.memoizedState) { + error( + "Expected %s state to match memoized state before " + + "processing the update queue. " + + "This might either be because of a bug in React, or because " + + "a component reassigns its own `this.props`. " + + "Please file an issue.", + getComponentName(finishedWork.type) || "instance" + ); + } } } // We could update instance props and state here, // but instead we rely on them being set during last render. @@ -18559,14 +17955,12 @@ function commitLifeCycles( case FundamentalComponent: case ScopeComponent: return; + } - 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 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." + ); } } @@ -18653,8 +18047,7 @@ function commitAttachRef(finishedWork) { } else { { if (!ref.hasOwnProperty("current")) { - warningWithoutStack$1( - false, + error( "Unexpected ref object provided for %s. " + "Use either a ref-setter function or React.createRef().%s", getComponentName(finishedWork.type), @@ -18689,7 +18082,8 @@ function commitUnmount(finishedRoot, current$$1, renderPriorityLevel) { case FunctionComponent: case ForwardRef: case MemoComponent: - case SimpleMemoComponent: { + case SimpleMemoComponent: + case Chunk: { var updateQueue = current$$1.updateQueue; if (updateQueue !== null) { @@ -18713,7 +18107,7 @@ function commitUnmount(finishedRoot, current$$1, renderPriorityLevel) { renderPriorityLevel > NormalPriority ? NormalPriority : renderPriorityLevel; - runWithPriority$1(priorityLevel, function() { + runWithPriority(priorityLevel, function() { var effect = firstEffect; do { @@ -18729,7 +18123,7 @@ function commitUnmount(finishedRoot, current$$1, renderPriorityLevel) { } } - break; + return; } case ClassComponent: { @@ -18744,27 +18138,9 @@ function commitUnmount(finishedRoot, current$$1, renderPriorityLevel) { } case HostComponent: { - if (enableFlareAPI) { - var dependencies = current$$1.dependencies; - - if (dependencies !== null) { - var respondersMap = dependencies.responders; - - if (respondersMap !== null) { - var responderInstances = Array.from(respondersMap.values()); - - for ( - var i = 0, length = responderInstances.length; - i < length; - i++ - ) { - var responderInstance = responderInstances[i]; - unmountResponderInstance(responderInstance); - } - - dependencies.responders = null; - } - } + if (enableDeprecatedFlareAPI) { + unmountDeprecatedResponderListeners(current$$1); + beforeRemoveInstance(current$$1.stateNode); } safelyDetachRef(current$$1); @@ -18814,9 +18190,15 @@ function commitUnmount(finishedRoot, current$$1, renderPriorityLevel) { } case ScopeComponent: { + if (enableDeprecatedFlareAPI) { + unmountDeprecatedResponderListeners(current$$1); + } + if (enableScopeAPI) { safelyDetachRef(current$$1); } + + return; } } } @@ -18877,6 +18259,7 @@ function detachFiber(current$$1) { current$$1.lastEffect = null; current$$1.pendingProps = null; current$$1.memoizedProps = null; + current$$1.stateNode = null; if (alternate !== null) { detachFiber(alternate); @@ -18913,14 +18296,12 @@ function commitContainer(finishedWork) { pendingChildren = portalOrRoot.pendingChildren; return; } + } - 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 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." + ); } } @@ -19256,7 +18637,8 @@ function commitWork(current$$1, finishedWork) { case FunctionComponent: case ForwardRef: case MemoComponent: - case SimpleMemoComponent: { + case SimpleMemoComponent: + case Chunk: { // Note: We currently never use MountMutation, but useLayout uses // UnmountMutation. commitHookEffectList(UnmountMutation, MountMutation, finishedWork); @@ -19301,7 +18683,8 @@ function commitWork(current$$1, finishedWork) { case FunctionComponent: case ForwardRef: case MemoComponent: - case SimpleMemoComponent: { + case SimpleMemoComponent: + case Chunk: { // Note: We currently never use MountMutation, but useLayout uses // UnmountMutation. commitHookEffectList(UnmountMutation, MountMutation, finishedWork); @@ -19339,12 +18722,12 @@ function commitWork(current$$1, finishedWork) { ); } - if (enableFlareAPI) { - var prevListeners = oldProps.listeners; - var nextListeners = newProps.listeners; + if (enableDeprecatedFlareAPI) { + var prevListeners = oldProps.DEPRECATED_flareListeners; + var nextListeners = newProps.DEPRECATED_flareListeners; if (prevListeners !== nextListeners) { - updateEventListeners(nextListeners, finishedWork, null); + updateDeprecatedEventListeners(nextListeners, finishedWork, null); } } } @@ -19406,9 +18789,10 @@ function commitWork(current$$1, finishedWork) { if (enableFundamentalAPI) { var fundamentalInstance = finishedWork.stateNode; updateFundamentalComponent(fundamentalInstance); + return; } - return; + break; } case ScopeComponent: { @@ -19416,31 +18800,31 @@ function commitWork(current$$1, finishedWork) { var scopeInstance = finishedWork.stateNode; scopeInstance.fiber = finishedWork; - if (enableFlareAPI) { + if (enableDeprecatedFlareAPI) { var _newProps = finishedWork.memoizedProps; var _oldProps = current$$1 !== null ? current$$1.memoizedProps : _newProps; - var _prevListeners = _oldProps.listeners; - var _nextListeners = _newProps.listeners; + var _prevListeners = _oldProps.DEPRECATED_flareListeners; + var _nextListeners = _newProps.DEPRECATED_flareListeners; - if (_prevListeners !== _nextListeners) { - updateEventListeners(_nextListeners, finishedWork, null); + if (_prevListeners !== _nextListeners || current$$1 === null) { + updateDeprecatedEventListeners(_nextListeners, finishedWork, null); } } + + return; } - return; + 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 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." + ); } } @@ -19472,7 +18856,7 @@ function commitSuspenseComponent(finishedWork) { } } else { if (suspenseCallback !== undefined) { - warning$1(false, "Unexpected type for suspenseCallback."); + error("Unexpected type for suspenseCallback."); } } } @@ -19565,10 +18949,10 @@ function createRootErrorUpdate(fiber, errorInfo, expirationTime) { update.payload = { element: null }; - var error = errorInfo.value; + var error$$1 = errorInfo.value; update.callback = function() { - onUncaughtError(error); + onUncaughtError(error$$1); logError(fiber, errorInfo); }; @@ -19581,11 +18965,11 @@ function createClassErrorUpdate(fiber, errorInfo, expirationTime) { var getDerivedStateFromError = fiber.type.getDerivedStateFromError; if (typeof getDerivedStateFromError === "function") { - var error = errorInfo.value; + var error$$1 = errorInfo.value; update.payload = function() { logError(fiber, errorInfo); - return getDerivedStateFromError(error); + return getDerivedStateFromError(error$$1); }; } @@ -19608,9 +18992,9 @@ function createClassErrorUpdate(fiber, errorInfo, expirationTime) { logError(fiber, errorInfo); } - var error = errorInfo.value; + var error$$1 = errorInfo.value; var stack = errorInfo.stack; - this.componentDidCatch(error, { + this.componentDidCatch(error$$1, { componentStack: stack !== null ? stack : "" }); @@ -19619,14 +19003,13 @@ function createClassErrorUpdate(fiber, errorInfo, expirationTime) { // If componentDidCatch is the only error boundary method defined, // then it needs to call setState to recover from errors. // If no state update is scheduled then the boundary will swallow the error. - !(fiber.expirationTime === Sync) - ? warningWithoutStack$1( - false, - "%s: Error boundaries should implement getDerivedStateFromError(). " + - "In that method, return a state update to display an error message or fallback UI.", - getComponentName(fiber.type) || "Unknown" - ) - : void 0; + if (fiber.expirationTime !== Sync) { + error( + "%s: Error boundaries should implement getDerivedStateFromError(). " + + "In that method, return a state update to display an error message or fallback UI.", + getComponentName(fiber.type) || "Unknown" + ); + } } } }; @@ -19691,6 +19074,20 @@ function throwException( ) { // This is a thenable. var thenable = value; + + if ((sourceFiber.mode & BlockingMode) === NoMode) { + // Reset the memoizedState to what it was before we attempted + // to render it. + var currentSource = sourceFiber.alternate; + + if (currentSource) { + sourceFiber.memoizedState = currentSource.memoizedState; + sourceFiber.expirationTime = currentSource.expirationTime; + } else { + sourceFiber.memoizedState = null; + } + } + checkForWrongSuspensePriorityInDEV(sourceFiber); var hasInvisibleParentBoundary = hasSuspenseContext( suspenseStackCursor.current, @@ -20015,7 +19412,7 @@ function computeExpirationForFiber(currentTime, fiber, suspenseConfig) { expirationTime = Sync; break; - case UserBlockingPriority$1: + case UserBlockingPriority: // TODO: Rename this to computeUserBlockingExpiration expirationTime = computeInteractiveExpiration(currentTime); break; @@ -20097,7 +19494,7 @@ function scheduleUpdateOnFiber(fiber, expirationTime) { if ( (executionContext & DiscreteEventContext) !== NoContext && // Only updates at user-blocking priority or greater are considered // discrete, even inside a discrete event. - (priorityLevel === UserBlockingPriority$1 || + (priorityLevel === UserBlockingPriority || priorityLevel === ImmediatePriority) ) { // This is the result of a discrete event. Track the lowest priority @@ -20216,9 +19613,21 @@ function getNextRootExpirationTimeToWorkOn(root) { var lastPingedTime = root.lastPingedTime; var nextKnownPendingLevel = root.nextKnownPendingLevel; - return lastPingedTime > nextKnownPendingLevel - ? lastPingedTime - : nextKnownPendingLevel; + var nextLevel = + lastPingedTime > nextKnownPendingLevel + ? lastPingedTime + : nextKnownPendingLevel; + + if ( + enableTrainModelFix && + nextLevel <= Idle && + firstPendingTime !== nextLevel + ) { + // Don't work on Idle/Never priority unless everything else is committed. + return NoWork; + } + + return nextLevel; } // Use this function to schedule a task for a root. There's only one task per // root; if a task was already scheduled, we'll check to make sure the // expiration time of the existing task is the same as the expiration time of @@ -20666,80 +20075,70 @@ function performSyncWorkOnRoot(root) { var lastExpiredTime = root.lastExpiredTime; var expirationTime = lastExpiredTime !== NoWork ? lastExpiredTime : Sync; - if (root.finishedExpirationTime === expirationTime) { - // There's already a pending commit at this expiration time. - // TODO: This is poorly factored. This case only exists for the - // batch.commit() API. - commitRoot(root); - } else { - if (!((executionContext & (RenderContext | CommitContext)) === NoContext)) { - throw Error("Should not already be working."); - } - - flushPassiveEffects(); // If the root or expiration time have changed, throw out the existing stack - // and prepare a fresh one. Otherwise we'll continue where we left off. - - if ( - root !== workInProgressRoot || - expirationTime !== renderExpirationTime - ) { - prepareFreshStack(root, expirationTime); - startWorkOnPendingInteractions(root, expirationTime); - } // If we have a work-in-progress fiber, it means there's still work to do - // in this root. + if (!((executionContext & (RenderContext | CommitContext)) === NoContext)) { + throw Error("Should not already be working."); + } - if (workInProgress !== null) { - var prevExecutionContext = executionContext; - executionContext |= RenderContext; - var prevDispatcher = pushDispatcher(root); - var prevInteractions = pushInteractions(root); - startWorkLoopTimer(workInProgress); + flushPassiveEffects(); // If the root or expiration time have changed, throw out the existing stack + // and prepare a fresh one. Otherwise we'll continue where we left off. - do { - try { - workLoopSync(); - break; - } catch (thrownValue) { - handleError(root, thrownValue); - } - } while (true); + if (root !== workInProgressRoot || expirationTime !== renderExpirationTime) { + prepareFreshStack(root, expirationTime); + startWorkOnPendingInteractions(root, expirationTime); + } // If we have a work-in-progress fiber, it means there's still work to do + // in this root. - resetContextDependencies(); - executionContext = prevExecutionContext; - popDispatcher(prevDispatcher); + if (workInProgress !== null) { + var prevExecutionContext = executionContext; + executionContext |= RenderContext; + var prevDispatcher = pushDispatcher(root); + var prevInteractions = pushInteractions(root); + startWorkLoopTimer(workInProgress); - if (enableSchedulerTracing) { - popInteractions(prevInteractions); + do { + try { + workLoopSync(); + break; + } catch (thrownValue) { + handleError(root, thrownValue); } + } while (true); - if (workInProgressRootExitStatus === RootFatalErrored) { - var fatalError = workInProgressRootFatalError; - stopInterruptedWorkLoopTimer(); - prepareFreshStack(root, expirationTime); - markRootSuspendedAtTime(root, expirationTime); - ensureRootIsScheduled(root); - throw fatalError; - } + resetContextDependencies(); + executionContext = prevExecutionContext; + popDispatcher(prevDispatcher); - if (workInProgress !== null) { - // This is a sync render, so we should have finished the whole tree. - { - throw Error( - "Cannot commit an incomplete root. This error is likely caused by a bug in React. Please file an issue." - ); - } - } else { - // We now have a consistent tree. Because this is a sync render, we - // will commit it even if something suspended. - stopFinishedWorkLoopTimer(); - root.finishedWork = root.current.alternate; - root.finishedExpirationTime = expirationTime; - finishSyncRender(root, workInProgressRootExitStatus, expirationTime); - } // Before exiting, make sure there's a callback scheduled for the next - // pending level. + if (enableSchedulerTracing) { + popInteractions(prevInteractions); + } + if (workInProgressRootExitStatus === RootFatalErrored) { + var fatalError = workInProgressRootFatalError; + stopInterruptedWorkLoopTimer(); + prepareFreshStack(root, expirationTime); + markRootSuspendedAtTime(root, expirationTime); ensureRootIsScheduled(root); + throw fatalError; } + + 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." + ); + } + } else { + // We now have a consistent tree. Because this is a sync render, we + // will commit it even if something suspended. + stopFinishedWorkLoopTimer(); + root.finishedWork = root.current.alternate; + root.finishedExpirationTime = expirationTime; + finishSyncRender(root, workInProgressRootExitStatus, expirationTime); + } // Before exiting, make sure there's a callback scheduled for the next + // pending level. + + ensureRootIsScheduled(root); } return null; @@ -20767,12 +20166,13 @@ function flushDiscreteUpdates() { (executionContext & (BatchedContext | RenderContext | CommitContext)) !== NoContext ) { - if (true && (executionContext & RenderContext) !== NoContext) { - warning$1( - false, - "unstable_flushDiscreteUpdates: Cannot flush updates when React is " + - "already rendering." - ); + { + if ((executionContext & RenderContext) !== NoContext) { + error( + "unstable_flushDiscreteUpdates: Cannot flush updates when React is " + + "already rendering." + ); + } } // We're already rendering, so we can't synchronously flush pending work. // This is probably a nested event dispatch triggered by a lifecycle/effect, // like `el.focus()`. Exit. @@ -20787,7 +20187,7 @@ function flushDiscreteUpdates() { } function syncUpdates(fn, a, b, c) { - return runWithPriority$1(ImmediatePriority, fn.bind(null, a, b, c)); + return runWithPriority(ImmediatePriority, fn.bind(null, a, b, c)); } function flushPendingDiscreteUpdates() { @@ -20841,7 +20241,7 @@ function discreteUpdates$1(fn, a, b, c) { try { // Should this - return runWithPriority$1(UserBlockingPriority$1, fn.bind(null, a, b, c)); + return runWithPriority(UserBlockingPriority, fn.bind(null, a, b, c)); } finally { executionContext = prevExecutionContext; @@ -20865,7 +20265,7 @@ function flushSync(fn, a) { executionContext |= BatchedContext; try { - return runWithPriority$1(ImmediatePriority, fn.bind(null, a)); + return runWithPriority(ImmediatePriority, fn.bind(null, a)); } finally { executionContext = prevExecutionContext; // Flush the immediate callbacks that were scheduled during this batch. // Note that this will happen even if batchedUpdates is higher up @@ -21350,7 +20750,7 @@ function resetChildExpirationTime(completedWork) { function commitRoot(root) { var renderPriorityLevel = getCurrentPriorityLevel(); - runWithPriority$1( + runWithPriority( ImmediatePriority, commitRootImpl.bind(null, root, renderPriorityLevel) ); @@ -21358,7 +20758,16 @@ function commitRoot(root) { } function commitRootImpl(root, renderPriorityLevel) { - flushPassiveEffects(); + do { + // `flushPassiveEffects` will call `flushSyncUpdateQueue` at the end, which + // means `flushPassiveEffects` will sometimes result in additional + // passive effects. So we need to keep flushing in a loop until there are + // no more pending effects. + // TODO: Might be better if `flushPassiveEffects` did not automatically + // flush synchronous work at the end, to avoid factoring hazards like this. + flushPassiveEffects(); + } while (rootWithPendingPassiveEffects !== null); + flushRenderPhaseStrictModeWarningsInDEV(); if (!((executionContext & (RenderContext | CommitContext)) === NoContext)) { @@ -21452,8 +20861,8 @@ function commitRootImpl(root, renderPriorityLevel) { throw Error("Should be working on an effect."); } - var error = clearCaughtError(); - captureCommitPhaseError(nextEffect, error); + var error$$1 = clearCaughtError(); + captureCommitPhaseError(nextEffect, error$$1); nextEffect = nextEffect.nextEffect; } } @@ -21789,7 +21198,7 @@ function flushPassiveEffects() { ? NormalPriority : pendingPassiveEffectsRenderPriority; pendingPassiveEffectsRenderPriority = NoPriority; - return runWithPriority$1(priorityLevel, flushPassiveEffectsImpl); + return runWithPriority(priorityLevel, flushPassiveEffectsImpl); } } @@ -21825,8 +21234,8 @@ function flushPassiveEffectsImpl() { throw Error("Should be working on an effect."); } - var error = clearCaughtError(); - captureCommitPhaseError(effect, error); + var error$$1 = clearCaughtError(); + captureCommitPhaseError(effect, error$$1); } resetCurrentFiber(); @@ -21866,17 +21275,17 @@ function markLegacyErrorBoundaryAsFailed(instance) { } } -function prepareToThrowUncaughtError(error) { +function prepareToThrowUncaughtError(error$$1) { if (!hasUncaughtError) { hasUncaughtError = true; - firstUncaughtError = error; + firstUncaughtError = error$$1; } } var onUncaughtError = prepareToThrowUncaughtError; -function captureCommitPhaseErrorOnRoot(rootFiber, sourceFiber, error) { - var errorInfo = createCapturedValue(error, sourceFiber); +function captureCommitPhaseErrorOnRoot(rootFiber, sourceFiber, error$$1) { + var errorInfo = createCapturedValue(error$$1, sourceFiber); var update = createRootErrorUpdate(rootFiber, errorInfo, Sync); enqueueUpdate(rootFiber, update); var root = markUpdateTimeFromFiberToRoot(rootFiber, Sync); @@ -21887,11 +21296,11 @@ function captureCommitPhaseErrorOnRoot(rootFiber, sourceFiber, error) { } } -function captureCommitPhaseError(sourceFiber, error) { +function captureCommitPhaseError(sourceFiber, error$$1) { if (sourceFiber.tag === HostRoot) { // Error was thrown at the root. There is no parent, so the root // itself should capture it. - captureCommitPhaseErrorOnRoot(sourceFiber, sourceFiber, error); + captureCommitPhaseErrorOnRoot(sourceFiber, sourceFiber, error$$1); return; } @@ -21899,7 +21308,7 @@ function captureCommitPhaseError(sourceFiber, error) { while (fiber !== null) { if (fiber.tag === HostRoot) { - captureCommitPhaseErrorOnRoot(fiber, sourceFiber, error); + captureCommitPhaseErrorOnRoot(fiber, sourceFiber, error$$1); return; } else if (fiber.tag === ClassComponent) { var ctor = fiber.type; @@ -21910,7 +21319,7 @@ function captureCommitPhaseError(sourceFiber, error) { (typeof instance.componentDidCatch === "function" && !isAlreadyFailedLegacyErrorBoundary(instance)) ) { - var errorInfo = createCapturedValue(error, sourceFiber); + var errorInfo = createCapturedValue(error$$1, sourceFiber); var update = createClassErrorUpdate( fiber, errorInfo, // TODO: This is always sync @@ -21984,7 +21393,7 @@ function pingSuspendedRoot(root, thenable, suspendedTime) { root.lastPingedTime = suspendedTime; - if (root.finishedExpirationTime === suspendedTime) { + if (!enableTrainModelFix && root.finishedExpirationTime === suspendedTime) { // If there's a pending fallback waiting to commit, throw it away. root.finishedExpirationTime = NoWork; root.finishedWork = null; @@ -22138,8 +21547,8 @@ function checkForNestedUpdates() { { if (nestedPassiveUpdateCount > NESTED_PASSIVE_UPDATE_LIMIT) { nestedPassiveUpdateCount = 0; - warning$1( - false, + + error( "Maximum update depth exceeded. This can happen when a component " + "calls setState inside useEffect, but useEffect either doesn't " + "have a dependency array, or one of the dependencies changes on " + @@ -22194,7 +21603,8 @@ function warnAboutUpdateOnUnmountedFiberInDEV(fiber) { tag !== FunctionComponent && tag !== ForwardRef && tag !== MemoComponent && - tag !== SimpleMemoComponent + tag !== SimpleMemoComponent && + tag !== Chunk ) { // Only warn for user-defined components, not internal ones like Suspense. return; @@ -22213,8 +21623,7 @@ function warnAboutUpdateOnUnmountedFiberInDEV(fiber) { didWarnStateUpdateForUnmountedComponent = new Set([componentName]); } - warningWithoutStack$1( - false, + error( "Can't perform a React state update on an unmounted component. This " + "is a no-op, but it indicates a memory leak in your application. To " + "fix, cancel all subscriptions and asynchronous tasks in %s.%s", @@ -22305,10 +21714,10 @@ function warnAboutInvalidUpdatesOnClassComponentsInDEV(fiber) { return; } - warningWithoutStack$1( - false, + error( "setState(...): Cannot call setState() inside getChildContext()" ); + didWarnAboutUpdateInGetChildContext = true; break; @@ -22317,12 +21726,12 @@ function warnAboutInvalidUpdatesOnClassComponentsInDEV(fiber) { return; } - warningWithoutStack$1( - false, + error( "Cannot update during an existing state transition (such as " + "within `render`). Render methods should be a pure function of " + "props and state." ); + didWarnAboutUpdateInRender = true; break; } @@ -22340,8 +21749,7 @@ function warnIfNotScopedWithMatchingAct(fiber) { IsSomeRendererActing.current === true && IsThisRendererActing.current !== true ) { - warningWithoutStack$1( - false, + 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" + @@ -22367,8 +21775,7 @@ function warnIfNotCurrentlyActingEffectsInDEV(fiber) { IsSomeRendererActing.current === false && IsThisRendererActing.current === false ) { - warningWithoutStack$1( - 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" + @@ -22395,8 +21802,7 @@ function warnIfNotCurrentlyActingUpdatesInDEV(fiber) { IsSomeRendererActing.current === false && IsThisRendererActing.current === false ) { - warningWithoutStack$1( - false, + error( "An update to %s inside a test was not wrapped in act(...).\n\n" + "When testing, code that causes React state updates should be " + "wrapped into act(...):\n\n" + @@ -22430,8 +21836,8 @@ function warnIfUnmockedScheduler(fiber) { ) { if (fiber.mode & BlockingMode || fiber.mode & ConcurrentMode) { didWarnAboutUnmockedScheduler = true; - warningWithoutStack$1( - false, + + 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" + @@ -22440,8 +21846,8 @@ function warnIfUnmockedScheduler(fiber) { ); } else if (warnAboutUnmockedScheduler === true) { didWarnAboutUnmockedScheduler = true; - warningWithoutStack$1( - false, + + error( 'Starting from React v17, the "scheduler" module will need to be mocked ' + "to guarantee consistent behaviour across tests and browsers. " + "For example, with jest: \n" + @@ -22459,7 +21865,7 @@ function checkForWrongSuspensePriorityInDEV(sourceFiber) { if ( (sourceFiber.mode & ConcurrentMode) !== NoEffect && - (currentPriorityLevel === UserBlockingPriority$1 || + (currentPriorityLevel === UserBlockingPriority || currentPriorityLevel === ImmediatePriority) ) { var workInProgressNode = sourceFiber; @@ -22478,13 +21884,13 @@ function checkForWrongSuspensePriorityInDEV(sourceFiber) { var updateQueue = current$$1.updateQueue; if (updateQueue !== null) { - var update = updateQueue.firstUpdate; + var update = updateQueue.baseQueue; while (update !== null) { var priorityLevel = update.priority; if ( - priorityLevel === UserBlockingPriority$1 || + priorityLevel === UserBlockingPriority || priorityLevel === ImmediatePriority ) { if (componentsThatTriggeredHighPriSuspend === null) { @@ -22509,18 +21915,18 @@ function checkForWrongSuspensePriorityInDEV(sourceFiber) { case FunctionComponent: case ForwardRef: case SimpleMemoComponent: - if ( - workInProgressNode.memoizedState !== null && - workInProgressNode.memoizedState.baseUpdate !== null - ) { - var _update = workInProgressNode.memoizedState.baseUpdate; // Loop through the functional component's memoized state to see whether + case Chunk: { + var firstHook = current$$1.memoizedState; // TODO: This just checks the first Hook. Isn't it suppose to check all Hooks? + + if (firstHook !== null && firstHook.baseQueue !== null) { + var _update = firstHook.baseQueue; // Loop through the functional component's memoized state to see whether // the component has triggered any high pri updates while (_update !== null) { var priority = _update.priority; if ( - priority === UserBlockingPriority$1 || + priority === UserBlockingPriority || priority === ImmediatePriority ) { if (componentsThatTriggeredHighPriSuspend === null) { @@ -22536,9 +21942,7 @@ function checkForWrongSuspensePriorityInDEV(sourceFiber) { break; } - if ( - _update.next === workInProgressNode.memoizedState.baseUpdate - ) { + if (_update.next === firstHook.baseQueue) { break; } @@ -22547,6 +21951,7 @@ function checkForWrongSuspensePriorityInDEV(sourceFiber) { } break; + } default: break; @@ -22569,8 +21974,7 @@ function flushSuspensePriorityWarningInDEV() { componentsThatTriggeredHighPriSuspend = null; if (componentNames.length > 0) { - warningWithoutStack$1( - false, + error( "%s triggered a user-blocking update that suspended." + "\n\n" + "The fix is to split the update into multiple parts: a user-blocking " + @@ -22683,10 +22087,10 @@ function startWorkOnPendingInteractions(root, expirationTime) { try { subscriber.onWorkStarted(interactions, threadID); - } catch (error) { + } catch (error$$1) { // If the subscriber throws, rethrow it in a separate task scheduleCallback(ImmediatePriority, function() { - throw error; + throw error$$1; }); } } @@ -22708,10 +22112,10 @@ function finishPendingInteractions(root, committedExpirationTime) { var threadID = computeThreadID(root, committedExpirationTime); subscriber.onWorkStopped(root.memoizedInteractions, threadID); } - } catch (error) { + } catch (error$$1) { // If the subscriber throws, rethrow it in a separate task scheduleCallback(ImmediatePriority, function() { - throw error; + throw error$$1; }); } finally { // Clear completed interactions from the pending Map. @@ -22733,10 +22137,10 @@ function finishPendingInteractions(root, committedExpirationTime) { if (subscriber !== null && interaction.__count === 0) { try { subscriber.onInteractionScheduledWorkCompleted(interaction); - } catch (error) { + } catch (error$$1) { // If the subscriber throws, rethrow it in a separate task scheduleCallback(ImmediatePriority, function() { - throw error; + throw error$$1; }); } } @@ -22746,6 +22150,7 @@ function finishPendingInteractions(root, committedExpirationTime) { } } +var onScheduleFiberRoot = null; var onCommitFiberRoot = null; var onCommitFiberUnmount = null; var hasLoggedError = false; @@ -22767,8 +22172,7 @@ function injectInternals(internals) { if (!hook.supportsFiber) { { - warningWithoutStack$1( - false, + error( "The installed version of React DevTools is too old and will not work " + "with the current version of React. Please update React DevTools. " + "https://fb.me/react-devtools" @@ -22781,6 +22185,23 @@ function injectInternals(internals) { try { var rendererID = hook.inject(internals); // We have successfully injected, so now it is safe to set up hooks. + { + // Only used by Fast Refresh + if (typeof hook.onScheduleFiberRoot === "function") { + onScheduleFiberRoot = function(root, children) { + try { + hook.onScheduleFiberRoot(rendererID, root, children); + } catch (err) { + if (true && !hasLoggedError) { + hasLoggedError = true; + + error("React instrumentation encountered an error: %s", err); + } + } + }; + } + } + onCommitFiberRoot = function(root, expirationTime) { try { var didError = (root.current.effectTag & DidCapture) === DidCapture; @@ -22796,13 +22217,12 @@ function injectInternals(internals) { hook.onCommitFiberRoot(rendererID, root, undefined, didError); } } catch (err) { - if (true && !hasLoggedError) { - hasLoggedError = true; - warningWithoutStack$1( - false, - "React DevTools encountered an error: %s", - err - ); + { + if (!hasLoggedError) { + hasLoggedError = true; + + error("React instrumentation encountered an error: %s", err); + } } } }; @@ -22811,29 +22231,29 @@ function injectInternals(internals) { try { hook.onCommitFiberUnmount(rendererID, fiber); } catch (err) { - if (true && !hasLoggedError) { - hasLoggedError = true; - warningWithoutStack$1( - false, - "React DevTools encountered an error: %s", - err - ); + { + if (!hasLoggedError) { + hasLoggedError = true; + + error("React instrumentation encountered an error: %s", err); + } } } }; } catch (err) { // Catch all errors because it is unsafe to throw during initialization. { - warningWithoutStack$1( - false, - "React DevTools encountered an error: %s.", - err - ); + error("React instrumentation encountered an error: %s.", err); } } // DevTools exists return true; } +function onScheduleRoot(root, children) { + if (typeof onScheduleFiberRoot === "function") { + onScheduleFiberRoot(root, children); + } +} function onCommitRoot(root, expirationTime) { if (typeof onCommitFiberRoot === "function") { onCommitFiberRoot(root, expirationTime); @@ -22981,6 +22401,12 @@ function resolveLazyComponentTag(Component) { if ($$typeof === REACT_MEMO_TYPE) { return MemoComponent; } + + if (enableChunksAPI) { + if ($$typeof === REACT_CHUNK_TYPE) { + return Chunk; + } + } } return IndeterminateComponent; @@ -23261,6 +22687,10 @@ function createFiberFromTypeAndProps( resolvedType = null; break getTag; + case REACT_CHUNK_TYPE: + fiberTag = Chunk; + break getTag; + case REACT_FUNDAMENTAL_TYPE: if (enableFundamentalAPI) { return createFiberFromFundamental( @@ -23386,8 +22816,7 @@ function createFiberFromProfiler(pendingProps, mode, expirationTime, key) { typeof pendingProps.id !== "string" || typeof pendingProps.onRender !== "function" ) { - warningWithoutStack$1( - false, + error( 'Profiler must specify an "id" string and "onRender" function as props' ); } @@ -23549,6 +22978,7 @@ function createFiberRoot(containerInfo, tag, hydrate, hydrationCallbacks) { var uninitializedFiber = createHostRootFiber(tag); root.current = uninitializedFiber; uninitializedFiber.stateNode = root; + initializeUpdateQueue(uninitializedFiber); return root; } function isRootSuspendedAtTime(root, expirationTime) { @@ -23642,15 +23072,6 @@ function markRootExpiredAtTime(root, expirationTime) { } } -// This lets us hook into Fiber to debug what it's doing. -// See https://github.com/facebook/react/pull/8033. -// This is not part of the public API, not even for React DevTools. -// You may only inject a debugTool if you work on React Fiber itself. -var ReactFiberInstrumentation = { - debugTool: null -}; -var ReactFiberInstrumentation_1 = ReactFiberInstrumentation; - var didWarnAboutNestedUpdates; var didWarnAboutFindNodeInStrictMode; @@ -23737,8 +23158,7 @@ function findHostInstanceWithWarning(component, methodName) { didWarnAboutFindNodeInStrictMode[componentName] = true; if (fiber.mode & StrictMode) { - warningWithoutStack$1( - false, + error( "%s is deprecated in StrictMode. " + "%s was passed an instance of %s which is inside StrictMode. " + "Instead, add a ref directly to the element you want to reference. " + @@ -23750,8 +23170,7 @@ function findHostInstanceWithWarning(component, methodName) { getStackByFiberInDevAndProd(hostFiber) ); } else { - warningWithoutStack$1( - false, + error( "%s is deprecated in StrictMode. " + "%s was passed an instance of %s which renders StrictMode children. " + "Instead, add a ref directly to the element you want to reference. " + @@ -23776,6 +23195,10 @@ function createContainer(containerInfo, tag, hydrate, hydrationCallbacks) { return createFiberRoot(containerInfo, tag, hydrate, hydrationCallbacks); } function updateContainer(element, container, parentComponent, callback) { + { + onScheduleRoot(container, element); + } + var current$$1 = container.current; var currentTime = requestCurrentTimeForUpdate(); @@ -23793,19 +23216,6 @@ function updateContainer(element, container, parentComponent, callback) { current$$1, suspenseConfig ); - - { - if (ReactFiberInstrumentation_1.debugTool) { - if (current$$1.alternate === null) { - ReactFiberInstrumentation_1.debugTool.onMountContainer(container); - } else if (element === null) { - ReactFiberInstrumentation_1.debugTool.onUnmountContainer(container); - } else { - ReactFiberInstrumentation_1.debugTool.onUpdateContainer(container); - } - } - } - var context = getContextForSubtree(parentComponent); if (container.context === null) { @@ -23817,8 +23227,8 @@ function updateContainer(element, container, parentComponent, callback) { { if (phase === "render" && current !== null && !didWarnAboutNestedUpdates) { didWarnAboutNestedUpdates = true; - warningWithoutStack$1( - false, + + error( "Render methods should be a pure function of props and state; " + "triggering nested component updates from render is not allowed. " + "If necessary, trigger nested updates in componentDidUpdate.\n\n" + @@ -23837,14 +23247,16 @@ function updateContainer(element, container, parentComponent, callback) { callback = callback === undefined ? null : callback; if (callback !== null) { - !(typeof callback === "function") - ? warningWithoutStack$1( - false, + { + if (typeof callback !== "function") { + error( "render(...): Expected the last optional `callback` argument to be a " + "function. Instead received: %s.", callback - ) - : void 0; + ); + } + } + update.callback = callback; } @@ -24002,7 +23414,7 @@ function createPortal( // TODO: this is special because it gets imported during build. -var ReactVersion = "16.11.0"; +var ReactVersion = "16.12.0-19f6fe170"; var NativeMethodsMixin = function(findNodeHandle, findHostInstance) { /** @@ -24046,7 +23458,7 @@ var NativeMethodsMixin = function(findNodeHandle, findHostInstance) { try { maybeInstance = findHostInstance(this); - } catch (error) {} // If there is no host component beneath this we should fail silently. + } catch (error$$1) {} // If there is no host component beneath this we should fail silently. // This is not an error; it could mean a class component rendered null. if (maybeInstance == null) { @@ -24092,7 +23504,7 @@ var NativeMethodsMixin = function(findNodeHandle, findHostInstance) { try { maybeInstance = findHostInstance(this); - } catch (error) {} // If there is no host component beneath this we should fail silently. + } catch (error$$1) {} // If there is no host component beneath this we should fail silently. // This is not an error; it could mean a class component rendered null. if (maybeInstance == null) { @@ -24136,7 +23548,7 @@ var NativeMethodsMixin = function(findNodeHandle, findHostInstance) { try { maybeInstance = findHostInstance(this); - } catch (error) {} // If there is no host component beneath this we should fail silently. + } catch (error$$1) {} // If there is no host component beneath this we should fail silently. // This is not an error; it could mean a class component rendered null. if (maybeInstance == null) { @@ -24144,12 +23556,14 @@ var NativeMethodsMixin = function(findNodeHandle, findHostInstance) { } if (maybeInstance.canonical) { - warningWithoutStack$1( - false, - "Warning: measureLayout on components using NativeMethodsMixin " + - "or ReactNative.NativeComponent is not currently supported in Fabric. " + - "measureLayout must be called on a native ref. Consider using forwardRef." - ); + { + error( + "Warning: measureLayout on components using NativeMethodsMixin " + + "or ReactNative.NativeComponent is not currently supported in Fabric. " + + "measureLayout must be called on a native ref. Consider using forwardRef." + ); + } + return; } else { var relativeNode; @@ -24162,10 +23576,12 @@ var NativeMethodsMixin = function(findNodeHandle, findHostInstance) { } if (relativeNode == null) { - warningWithoutStack$1( - false, - "Warning: ref.measureLayout must be called with a node handle or a ref to a native component." - ); + { + error( + "Warning: ref.measureLayout must be called with a node handle or a ref to a native component." + ); + } + return; } @@ -24197,7 +23613,7 @@ var NativeMethodsMixin = function(findNodeHandle, findHostInstance) { try { maybeInstance = findHostInstance(this); - } catch (error) {} // If there is no host component beneath this we should fail silently. + } catch (error$$1) {} // If there is no host component beneath this we should fail silently. // This is not an error; it could mean a class component rendered null. if (maybeInstance == null) { @@ -24205,10 +23621,10 @@ var NativeMethodsMixin = function(findNodeHandle, findHostInstance) { } if (maybeInstance.canonical) { - warningWithoutStack$1( - false, - "Warning: setNativeProps is not currently supported in Fabric" - ); + { + error("Warning: setNativeProps is not currently supported in Fabric"); + } + return; } @@ -24299,7 +23715,13 @@ var NativeMethodsMixin = function(findNodeHandle, findHostInstance) { return NativeMethodsMixin; }; -var ReactNativeComponent$1 = function(findNodeHandle, findHostInstance) { +function _inheritsLoose(subClass, superClass) { + subClass.prototype = Object.create(superClass.prototype); + subClass.prototype.constructor = subClass; + subClass.__proto__ = superClass; +} + +var ReactNativeComponent = function(findNodeHandle, findHostInstance) { /** * Superclass that provides methods to access the underlying native component. * This can be useful when you want to focus a view or measure its dimensions. @@ -24368,7 +23790,7 @@ var ReactNativeComponent$1 = function(findNodeHandle, findHostInstance) { try { maybeInstance = findHostInstance(this); - } catch (error) {} // If there is no host component beneath this we should fail silently. + } catch (error$$1) {} // If there is no host component beneath this we should fail silently. // This is not an error; it could mean a class component rendered null. if (maybeInstance == null) { @@ -24412,7 +23834,7 @@ var ReactNativeComponent$1 = function(findNodeHandle, findHostInstance) { try { maybeInstance = findHostInstance(this); - } catch (error) {} // If there is no host component beneath this we should fail silently. + } catch (error$$1) {} // If there is no host component beneath this we should fail silently. // This is not an error; it could mean a class component rendered null. if (maybeInstance == null) { @@ -24453,7 +23875,7 @@ var ReactNativeComponent$1 = function(findNodeHandle, findHostInstance) { try { maybeInstance = findHostInstance(this); - } catch (error) {} // If there is no host component beneath this we should fail silently. + } catch (error$$1) {} // If there is no host component beneath this we should fail silently. // This is not an error; it could mean a class component rendered null. if (maybeInstance == null) { @@ -24461,12 +23883,14 @@ var ReactNativeComponent$1 = function(findNodeHandle, findHostInstance) { } if (maybeInstance.canonical) { - warningWithoutStack$1( - false, - "Warning: measureLayout on components using NativeMethodsMixin " + - "or ReactNative.NativeComponent is not currently supported in Fabric. " + - "measureLayout must be called on a native ref. Consider using forwardRef." - ); + { + error( + "Warning: measureLayout on components using NativeMethodsMixin " + + "or ReactNative.NativeComponent is not currently supported in Fabric. " + + "measureLayout must be called on a native ref. Consider using forwardRef." + ); + } + return; } else { var relativeNode; @@ -24479,10 +23903,12 @@ var ReactNativeComponent$1 = function(findNodeHandle, findHostInstance) { } if (relativeNode == null) { - warningWithoutStack$1( - false, - "Warning: ref.measureLayout must be called with a node handle or a ref to a native component." - ); + { + error( + "Warning: ref.measureLayout must be called with a node handle or a ref to a native component." + ); + } + return; } @@ -24514,7 +23940,7 @@ var ReactNativeComponent$1 = function(findNodeHandle, findHostInstance) { try { maybeInstance = findHostInstance(this); - } catch (error) {} // If there is no host component beneath this we should fail silently. + } catch (error$$1) {} // If there is no host component beneath this we should fail silently. // This is not an error; it could mean a class component rendered null. if (maybeInstance == null) { @@ -24522,10 +23948,12 @@ var ReactNativeComponent$1 = function(findNodeHandle, findHostInstance) { } if (maybeInstance.canonical) { - warningWithoutStack$1( - false, - "Warning: setNativeProps is not currently supported in Fabric" - ); + { + error( + "Warning: setNativeProps is not currently supported in Fabric" + ); + } + return; } @@ -24669,8 +24097,6 @@ var getInspectorDataForViewTag; }; } -var _nativeFabricUIManage = nativeFabricUIManager; -var fabricDispatchCommand = _nativeFabricUIManage.dispatchCommand; var ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner; function findHostInstance_DEPRECATED(componentOrHandle) { @@ -24678,17 +24104,17 @@ function findHostInstance_DEPRECATED(componentOrHandle) { var owner = ReactCurrentOwner.current; if (owner !== null && owner.stateNode !== null) { - !owner.stateNode._warnedAboutRefsInRender - ? warningWithoutStack$1( - false, - "%s is accessing findNodeHandle inside its render(). " + - "render() should be a pure function of props and state. It should " + - "never access something that requires stale data from the previous " + - "render, such as refs. Move this logic to componentDidMount and " + - "componentDidUpdate instead.", - getComponentName(owner.type) || "A component" - ) - : void 0; + if (!owner.stateNode._warnedAboutRefsInRender) { + error( + "%s is accessing findNodeHandle inside its render(). " + + "render() should be a pure function of props and state. It should " + + "never access something that requires stale data from the previous " + + "render, such as refs. Move this logic to componentDidMount and " + + "componentDidUpdate instead.", + getComponentName(owner.type) || "A component" + ); + } + owner.stateNode._warnedAboutRefsInRender = true; } } @@ -24731,17 +24157,17 @@ function findNodeHandle(componentOrHandle) { var owner = ReactCurrentOwner.current; if (owner !== null && owner.stateNode !== null) { - !owner.stateNode._warnedAboutRefsInRender - ? warningWithoutStack$1( - false, - "%s is accessing findNodeHandle inside its render(). " + - "render() should be a pure function of props and state. It should " + - "never access something that requires stale data from the previous " + - "render, such as refs. Move this logic to componentDidMount and " + - "componentDidUpdate instead.", - getComponentName(owner.type) || "A component" - ) - : void 0; + if (!owner.stateNode._warnedAboutRefsInRender) { + error( + "%s is accessing findNodeHandle inside its render(). " + + "render() should be a pure function of props and state. It should " + + "never access something that requires stale data from the previous " + + "render, such as refs. Move this logic to componentDidMount and " + + "componentDidUpdate instead.", + getComponentName(owner.type) || "A component" + ); + } + owner.stateNode._warnedAboutRefsInRender = true; } } @@ -24793,31 +24219,36 @@ setBatchingImplementation( ); var roots = new Map(); var ReactFabric = { - NativeComponent: ReactNativeComponent$1(findNodeHandle, findHostInstance), + NativeComponent: ReactNativeComponent(findNodeHandle, findHostInstance), // This is needed for implementation details of TouchableNativeFeedback // Remove this once TouchableNativeFeedback doesn't use cloneElement findHostInstance_DEPRECATED: findHostInstance_DEPRECATED, findNodeHandle: findNodeHandle, dispatchCommand: function(handle, command, args) { - var invalid = - handle._nativeTag == null || handle._internalInstanceHandle == null; - - if (invalid) { - !!invalid - ? warningWithoutStack$1( - false, - "dispatchCommand was called with a ref that isn't a " + - "native component. Use React.forwardRef to get access to the underlying native component" - ) - : void 0; + if (handle._nativeTag == null) { + { + error( + "dispatchCommand was called with a ref that isn't a " + + "native component. Use React.forwardRef to get access to the underlying native component" + ); + } + return; } - fabricDispatchCommand( - handle._internalInstanceHandle.stateNode.node, - command, - args - ); + if (handle._internalInstanceHandle) { + nativeFabricUIManager.dispatchCommand( + handle._internalInstanceHandle.stateNode.node, + command, + args + ); + } else { + ReactNativePrivateInterface.UIManager.dispatchViewManagerCommand( + handle._nativeTag, + command, + args + ); + } }, render: function(element, containerTag, callback) { var root = roots.get(containerTag); diff --git a/Libraries/Renderer/implementations/ReactFabric-prod.fb.js b/Libraries/Renderer/implementations/ReactFabric-prod.fb.js index 1977c28b91768a..3ff91b8b31675a 100644 --- a/Libraries/Renderer/implementations/ReactFabric-prod.fb.js +++ b/Libraries/Renderer/implementations/ReactFabric-prod.fb.js @@ -502,53 +502,27 @@ function recordTouchStart(touch) { } function recordTouchMove(touch) { var touchRecord = touchBank[getTouchIdentifier(touch)]; - touchRecord - ? ((touchRecord.touchActive = !0), - (touchRecord.previousPageX = touchRecord.currentPageX), - (touchRecord.previousPageY = touchRecord.currentPageY), - (touchRecord.previousTimeStamp = touchRecord.currentTimeStamp), - (touchRecord.currentPageX = touch.pageX), - (touchRecord.currentPageY = touch.pageY), - (touchRecord.currentTimeStamp = timestampForTouch(touch)), - (touchHistory.mostRecentTimeStamp = timestampForTouch(touch))) - : console.warn( - "Cannot record touch move without a touch start.\nTouch Move: %s\n", - "Touch Bank: %s", - printTouch(touch), - printTouchBank() - ); + touchRecord && + ((touchRecord.touchActive = !0), + (touchRecord.previousPageX = touchRecord.currentPageX), + (touchRecord.previousPageY = touchRecord.currentPageY), + (touchRecord.previousTimeStamp = touchRecord.currentTimeStamp), + (touchRecord.currentPageX = touch.pageX), + (touchRecord.currentPageY = touch.pageY), + (touchRecord.currentTimeStamp = timestampForTouch(touch)), + (touchHistory.mostRecentTimeStamp = timestampForTouch(touch))); } function recordTouchEnd(touch) { var touchRecord = touchBank[getTouchIdentifier(touch)]; - touchRecord - ? ((touchRecord.touchActive = !1), - (touchRecord.previousPageX = touchRecord.currentPageX), - (touchRecord.previousPageY = touchRecord.currentPageY), - (touchRecord.previousTimeStamp = touchRecord.currentTimeStamp), - (touchRecord.currentPageX = touch.pageX), - (touchRecord.currentPageY = touch.pageY), - (touchRecord.currentTimeStamp = timestampForTouch(touch)), - (touchHistory.mostRecentTimeStamp = timestampForTouch(touch))) - : console.warn( - "Cannot record touch end without a touch start.\nTouch End: %s\n", - "Touch Bank: %s", - printTouch(touch), - printTouchBank() - ); -} -function printTouch(touch) { - return JSON.stringify({ - identifier: touch.identifier, - pageX: touch.pageX, - pageY: touch.pageY, - timestamp: timestampForTouch(touch) - }); -} -function printTouchBank() { - var printed = JSON.stringify(touchBank.slice(0, 20)); - 20 < touchBank.length && - (printed += " (original size: " + touchBank.length + ")"); - return printed; + touchRecord && + ((touchRecord.touchActive = !1), + (touchRecord.previousPageX = touchRecord.currentPageX), + (touchRecord.previousPageY = touchRecord.currentPageY), + (touchRecord.previousTimeStamp = touchRecord.currentTimeStamp), + (touchRecord.currentPageX = touch.pageX), + (touchRecord.currentPageY = touch.pageY), + (touchRecord.currentTimeStamp = timestampForTouch(touch)), + (touchHistory.mostRecentTimeStamp = timestampForTouch(touch))); } var ResponderTouchHistoryStore = { recordTouchTrack: function(topLevelType, nativeEvent) { @@ -681,13 +655,7 @@ var eventTypes = { "topTouchCancel" === topLevelType ) if (0 <= trackedTouchCount) --trackedTouchCount; - else - return ( - console.warn( - "Ended a touch event which was not counted in `trackedTouchCount`." - ), - null - ); + else return null; ResponderTouchHistoryStore.recordTouchTrack(topLevelType, nativeEvent); if ( targetInst && @@ -1042,7 +1010,8 @@ var hasSymbol = "function" === typeof Symbol && Symbol.for, ? Symbol.for("react.suspense_list") : 60120, REACT_MEMO_TYPE = hasSymbol ? Symbol.for("react.memo") : 60115, - REACT_LAZY_TYPE = hasSymbol ? Symbol.for("react.lazy") : 60116; + REACT_LAZY_TYPE = hasSymbol ? Symbol.for("react.lazy") : 60116, + REACT_CHUNK_TYPE = hasSymbol ? Symbol.for("react.chunk") : 60121; hasSymbol && Symbol.for("react.fundamental"); hasSymbol && Symbol.for("react.responder"); hasSymbol && Symbol.for("react.scope"); @@ -1107,6 +1076,8 @@ function getComponentName(type) { ); case REACT_MEMO_TYPE: return getComponentName(type.type); + case REACT_CHUNK_TYPE: + return getComponentName(type.render); case REACT_LAZY_TYPE: if ((type = 1 === type._status ? type._result : null)) return getComponentName(type); @@ -1494,26 +1465,6 @@ function batchedUpdates(fn, bookkeeping) { restoreStateOfTarget(fn[bookkeeping]); } } -function _inheritsLoose(subClass, superClass) { - subClass.prototype = Object.create(superClass.prototype); - subClass.prototype.constructor = subClass; - subClass.__proto__ = superClass; -} -(function(_React$Component) { - function ReactNativeComponent() { - return _React$Component.apply(this, arguments) || this; - } - _inheritsLoose(ReactNativeComponent, _React$Component); - var _proto = ReactNativeComponent.prototype; - _proto.blur = function() {}; - _proto.focus = function() {}; - _proto.measure = function() {}; - _proto.measureInWindow = function() {}; - _proto.measureLayout = function() {}; - _proto.setNativeProps = function() {}; - return ReactNativeComponent; -})(React.Component); -new Map(); function dispatchEvent(target, topLevelType, nativeEvent) { var eventTarget = null; enableNativeTargetAsInstance @@ -1556,21 +1507,21 @@ function shim$1() { "The current renderer does not support hydration. This error is likely caused by a bug in React. Please file an issue." ); } -var _nativeFabricUIManage$1 = nativeFabricUIManager, - createNode = _nativeFabricUIManage$1.createNode, - cloneNode = _nativeFabricUIManage$1.cloneNode, - cloneNodeWithNewChildren = _nativeFabricUIManage$1.cloneNodeWithNewChildren, +var _nativeFabricUIManage = nativeFabricUIManager, + createNode = _nativeFabricUIManage.createNode, + cloneNode = _nativeFabricUIManage.cloneNode, + cloneNodeWithNewChildren = _nativeFabricUIManage.cloneNodeWithNewChildren, cloneNodeWithNewChildrenAndProps = - _nativeFabricUIManage$1.cloneNodeWithNewChildrenAndProps, - cloneNodeWithNewProps = _nativeFabricUIManage$1.cloneNodeWithNewProps, - createChildNodeSet = _nativeFabricUIManage$1.createChildSet, - appendChildNode = _nativeFabricUIManage$1.appendChild, - appendChildNodeToSet = _nativeFabricUIManage$1.appendChildToSet, - completeRoot = _nativeFabricUIManage$1.completeRoot, - registerEventHandler = _nativeFabricUIManage$1.registerEventHandler, - fabricMeasure = _nativeFabricUIManage$1.measure, - fabricMeasureInWindow = _nativeFabricUIManage$1.measureInWindow, - fabricMeasureLayout = _nativeFabricUIManage$1.measureLayout, + _nativeFabricUIManage.cloneNodeWithNewChildrenAndProps, + cloneNodeWithNewProps = _nativeFabricUIManage.cloneNodeWithNewProps, + createChildNodeSet = _nativeFabricUIManage.createChildSet, + appendChildNode = _nativeFabricUIManage.appendChild, + appendChildNodeToSet = _nativeFabricUIManage.appendChildToSet, + completeRoot = _nativeFabricUIManage.completeRoot, + registerEventHandler = _nativeFabricUIManage.registerEventHandler, + fabricMeasure = _nativeFabricUIManage.measure, + fabricMeasureInWindow = _nativeFabricUIManage.measureInWindow, + fabricMeasureLayout = _nativeFabricUIManage.measureLayout, getViewConfigForType = ReactNativePrivateInterface.ReactNativeViewConfigRegistry.get, nextReactTag = 2; @@ -1847,7 +1798,7 @@ function reactPriorityToSchedulerPriority(reactPriorityLevel) { throw Error("Unknown priority level."); } } -function runWithPriority$1(reactPriorityLevel, fn) { +function runWithPriority(reactPriorityLevel, fn) { reactPriorityLevel = reactPriorityToSchedulerPriority(reactPriorityLevel); return Scheduler_runWithPriority(reactPriorityLevel, fn); } @@ -1879,7 +1830,7 @@ function flushSyncCallbackQueueImpl() { var i = 0; try { var queue = syncQueue; - runWithPriority$1(99, function() { + runWithPriority(99, function() { for (; i < queue.length; i++) { var callback = queue[i]; do callback = callback(!0); @@ -2003,237 +1954,195 @@ function readContext(context, observedBits) { return context._currentValue2; } var hasForceUpdate = !1; -function createUpdateQueue(baseState) { - return { - baseState: baseState, - firstUpdate: null, - lastUpdate: null, - firstCapturedUpdate: null, - lastCapturedUpdate: null, - firstEffect: null, - lastEffect: null, - firstCapturedEffect: null, - lastCapturedEffect: null +function initializeUpdateQueue(fiber) { + fiber.updateQueue = { + baseState: fiber.memoizedState, + baseQueue: null, + shared: { pending: null }, + effects: null }; } -function cloneUpdateQueue(currentQueue) { - return { - baseState: currentQueue.baseState, - firstUpdate: currentQueue.firstUpdate, - lastUpdate: currentQueue.lastUpdate, - firstCapturedUpdate: null, - lastCapturedUpdate: null, - firstEffect: null, - lastEffect: null, - firstCapturedEffect: null, - lastCapturedEffect: null - }; +function cloneUpdateQueue(current, workInProgress) { + current = current.updateQueue; + workInProgress.updateQueue === current && + (workInProgress.updateQueue = { + baseState: current.baseState, + baseQueue: current.baseQueue, + shared: current.shared, + effects: current.effects + }); } function createUpdate(expirationTime, suspenseConfig) { - return { + expirationTime = { expirationTime: expirationTime, suspenseConfig: suspenseConfig, tag: 0, payload: null, callback: null, - next: null, - nextEffect: null + next: null }; -} -function appendUpdateToQueue(queue, update) { - null === queue.lastUpdate - ? (queue.firstUpdate = queue.lastUpdate = update) - : ((queue.lastUpdate.next = update), (queue.lastUpdate = update)); + return (expirationTime.next = expirationTime); } function enqueueUpdate(fiber, update) { - var alternate = fiber.alternate; - if (null === alternate) { - var queue1 = fiber.updateQueue; - var queue2 = null; - null === queue1 && - (queue1 = fiber.updateQueue = createUpdateQueue(fiber.memoizedState)); - } else - (queue1 = fiber.updateQueue), - (queue2 = alternate.updateQueue), - null === queue1 - ? null === queue2 - ? ((queue1 = fiber.updateQueue = createUpdateQueue( - fiber.memoizedState - )), - (queue2 = alternate.updateQueue = createUpdateQueue( - alternate.memoizedState - ))) - : (queue1 = fiber.updateQueue = cloneUpdateQueue(queue2)) - : null === queue2 && - (queue2 = alternate.updateQueue = cloneUpdateQueue(queue1)); - null === queue2 || queue1 === queue2 - ? appendUpdateToQueue(queue1, update) - : null === queue1.lastUpdate || null === queue2.lastUpdate - ? (appendUpdateToQueue(queue1, update), - appendUpdateToQueue(queue2, update)) - : (appendUpdateToQueue(queue1, update), (queue2.lastUpdate = update)); + fiber = fiber.updateQueue; + if (null !== fiber) { + fiber = fiber.shared; + var pending = fiber.pending; + null === pending + ? (update.next = update) + : ((update.next = pending.next), (pending.next = update)); + fiber.pending = update; + } } function enqueueCapturedUpdate(workInProgress, update) { - var workInProgressQueue = workInProgress.updateQueue; - workInProgressQueue = - null === workInProgressQueue - ? (workInProgress.updateQueue = createUpdateQueue( - workInProgress.memoizedState - )) - : ensureWorkInProgressQueueIsAClone(workInProgress, workInProgressQueue); - null === workInProgressQueue.lastCapturedUpdate - ? (workInProgressQueue.firstCapturedUpdate = workInProgressQueue.lastCapturedUpdate = update) - : ((workInProgressQueue.lastCapturedUpdate.next = update), - (workInProgressQueue.lastCapturedUpdate = update)); -} -function ensureWorkInProgressQueueIsAClone(workInProgress, queue) { var current = workInProgress.alternate; - null !== current && - queue === current.updateQueue && - (queue = workInProgress.updateQueue = cloneUpdateQueue(queue)); - return queue; -} -function getStateFromUpdate( - workInProgress, - queue, - update, - prevState, - nextProps, - instance -) { - switch (update.tag) { - case 1: - return ( - (workInProgress = update.payload), - "function" === typeof workInProgress - ? workInProgress.call(instance, prevState, nextProps) - : workInProgress - ); - case 3: - workInProgress.effectTag = (workInProgress.effectTag & -4097) | 64; - case 0: - workInProgress = update.payload; - nextProps = - "function" === typeof workInProgress - ? workInProgress.call(instance, prevState, nextProps) - : workInProgress; - if (null === nextProps || void 0 === nextProps) break; - return Object.assign({}, prevState, nextProps); - case 2: - hasForceUpdate = !0; - } - return prevState; + null !== current && cloneUpdateQueue(current, workInProgress); + workInProgress = workInProgress.updateQueue; + current = workInProgress.baseQueue; + null === current + ? ((workInProgress.baseQueue = update.next = update), + (update.next = update)) + : ((update.next = current.next), (current.next = update)); } function processUpdateQueue( - workInProgress, - queue, + workInProgress$jscomp$0, props, instance, renderExpirationTime ) { + var queue = workInProgress$jscomp$0.updateQueue; hasForceUpdate = !1; - queue = ensureWorkInProgressQueueIsAClone(workInProgress, queue); - for ( - var newBaseState = queue.baseState, - newFirstUpdate = null, - newExpirationTime = 0, - update = queue.firstUpdate, - resultState = newBaseState; - null !== update; - - ) { - var updateExpirationTime = update.expirationTime; - updateExpirationTime < renderExpirationTime - ? (null === newFirstUpdate && - ((newFirstUpdate = update), (newBaseState = resultState)), - newExpirationTime < updateExpirationTime && - (newExpirationTime = updateExpirationTime)) - : (markRenderEventTimeAndConfig( - updateExpirationTime, - update.suspenseConfig - ), - (resultState = getStateFromUpdate( - workInProgress, - queue, - update, - resultState, - props, - instance - )), - null !== update.callback && - ((workInProgress.effectTag |= 32), - (update.nextEffect = null), - null === queue.lastEffect - ? (queue.firstEffect = queue.lastEffect = update) - : ((queue.lastEffect.nextEffect = update), - (queue.lastEffect = update)))); - update = update.next; + var baseQueue = queue.baseQueue, + pendingQueue = queue.shared.pending; + if (null !== pendingQueue) { + if (null !== baseQueue) { + var baseFirst = baseQueue.next; + baseQueue.next = pendingQueue.next; + pendingQueue.next = baseFirst; + } + baseQueue = pendingQueue; + queue.shared.pending = null; + baseFirst = workInProgress$jscomp$0.alternate; + null !== baseFirst && + ((baseFirst = baseFirst.updateQueue), + null !== baseFirst && (baseFirst.baseQueue = pendingQueue)); } - updateExpirationTime = null; - for (update = queue.firstCapturedUpdate; null !== update; ) { - var _updateExpirationTime = update.expirationTime; - _updateExpirationTime < renderExpirationTime - ? (null === updateExpirationTime && - ((updateExpirationTime = update), - null === newFirstUpdate && (newBaseState = resultState)), - newExpirationTime < _updateExpirationTime && - (newExpirationTime = _updateExpirationTime)) - : ((resultState = getStateFromUpdate( - workInProgress, - queue, - update, - resultState, - props, - instance - )), - null !== update.callback && - ((workInProgress.effectTag |= 32), - (update.nextEffect = null), - null === queue.lastCapturedEffect - ? (queue.firstCapturedEffect = queue.lastCapturedEffect = update) - : ((queue.lastCapturedEffect.nextEffect = update), - (queue.lastCapturedEffect = update)))); - update = update.next; + if (null !== baseQueue) { + baseFirst = baseQueue.next; + var newState = queue.baseState, + newExpirationTime = 0, + newBaseState = null, + newBaseQueueFirst = null, + newBaseQueueLast = null; + if (null !== baseFirst) { + var update = baseFirst; + do { + pendingQueue = update.expirationTime; + if (pendingQueue < renderExpirationTime) { + var clone = { + expirationTime: update.expirationTime, + suspenseConfig: update.suspenseConfig, + tag: update.tag, + payload: update.payload, + callback: update.callback, + next: null + }; + null === newBaseQueueLast + ? ((newBaseQueueFirst = newBaseQueueLast = clone), + (newBaseState = newState)) + : (newBaseQueueLast = newBaseQueueLast.next = clone); + pendingQueue > newExpirationTime && + (newExpirationTime = pendingQueue); + } else { + null !== newBaseQueueLast && + (newBaseQueueLast = newBaseQueueLast.next = { + expirationTime: 1073741823, + suspenseConfig: update.suspenseConfig, + tag: update.tag, + payload: update.payload, + callback: update.callback, + next: null + }); + markRenderEventTimeAndConfig(pendingQueue, update.suspenseConfig); + a: { + var workInProgress = workInProgress$jscomp$0, + update$jscomp$0 = update; + pendingQueue = props; + clone = instance; + switch (update$jscomp$0.tag) { + case 1: + workInProgress = update$jscomp$0.payload; + if ("function" === typeof workInProgress) { + newState = workInProgress.call(clone, newState, pendingQueue); + break a; + } + newState = workInProgress; + break a; + case 3: + workInProgress.effectTag = + (workInProgress.effectTag & -4097) | 64; + case 0: + workInProgress = update$jscomp$0.payload; + pendingQueue = + "function" === typeof workInProgress + ? workInProgress.call(clone, newState, pendingQueue) + : workInProgress; + if (null === pendingQueue || void 0 === pendingQueue) break a; + newState = Object.assign({}, newState, pendingQueue); + break a; + case 2: + hasForceUpdate = !0; + } + } + null !== update.callback && + ((workInProgress$jscomp$0.effectTag |= 32), + (pendingQueue = queue.effects), + null === pendingQueue + ? (queue.effects = [update]) + : pendingQueue.push(update)); + } + update = update.next; + if (null === update || update === baseFirst) + if (((pendingQueue = queue.shared.pending), null === pendingQueue)) + break; + else + (update = baseQueue.next = pendingQueue.next), + (pendingQueue.next = baseFirst), + (queue.baseQueue = baseQueue = pendingQueue), + (queue.shared.pending = null); + } while (1); + } + null === newBaseQueueLast + ? (newBaseState = newState) + : (newBaseQueueLast.next = newBaseQueueFirst); + queue.baseState = newBaseState; + queue.baseQueue = newBaseQueueLast; + markUnprocessedUpdateTime(newExpirationTime); + workInProgress$jscomp$0.expirationTime = newExpirationTime; + workInProgress$jscomp$0.memoizedState = newState; } - null === newFirstUpdate && (queue.lastUpdate = null); - null === updateExpirationTime - ? (queue.lastCapturedUpdate = null) - : (workInProgress.effectTag |= 32); - null === newFirstUpdate && - null === updateExpirationTime && - (newBaseState = resultState); - queue.baseState = newBaseState; - queue.firstUpdate = newFirstUpdate; - queue.firstCapturedUpdate = updateExpirationTime; - markUnprocessedUpdateTime(newExpirationTime); - workInProgress.expirationTime = newExpirationTime; - workInProgress.memoizedState = resultState; } function commitUpdateQueue(finishedWork, finishedQueue, instance) { - null !== finishedQueue.firstCapturedUpdate && - (null !== finishedQueue.lastUpdate && - ((finishedQueue.lastUpdate.next = finishedQueue.firstCapturedUpdate), - (finishedQueue.lastUpdate = finishedQueue.lastCapturedUpdate)), - (finishedQueue.firstCapturedUpdate = finishedQueue.lastCapturedUpdate = null)); - commitUpdateEffects(finishedQueue.firstEffect, instance); - finishedQueue.firstEffect = finishedQueue.lastEffect = null; - commitUpdateEffects(finishedQueue.firstCapturedEffect, instance); - finishedQueue.firstCapturedEffect = finishedQueue.lastCapturedEffect = null; -} -function commitUpdateEffects(effect, instance) { - for (; null !== effect; ) { - var callback = effect.callback; - if (null !== callback) { - effect.callback = null; - if ("function" !== typeof callback) - throw Error( - "Invalid argument passed as callback. Expected a function. Instead received: " + - callback - ); - callback.call(instance); + finishedWork = finishedQueue.effects; + finishedQueue.effects = null; + if (null !== finishedWork) + for ( + finishedQueue = 0; + finishedQueue < finishedWork.length; + finishedQueue++ + ) { + var effect = finishedWork[finishedQueue], + callback = effect.callback; + if (null !== callback) { + effect.callback = null; + if ("function" !== typeof callback) + throw Error( + "Invalid argument passed as callback. Expected a function. Instead received: " + + callback + ); + callback.call(instance); + } } - effect = effect.nextEffect; - } } var ReactCurrentBatchConfig = ReactSharedInternals.ReactCurrentBatchConfig, emptyRefsObject = new React.Component().refs; @@ -2250,10 +2159,8 @@ function applyDerivedStateFromProps( ? ctor : Object.assign({}, ctor, getDerivedStateFromProps); workInProgress.memoizedState = getDerivedStateFromProps; - nextProps = workInProgress.updateQueue; - null !== nextProps && - 0 === workInProgress.expirationTime && - (nextProps.baseState = getDerivedStateFromProps); + 0 === workInProgress.expirationTime && + (workInProgress.updateQueue.baseState = getDerivedStateFromProps); } var classComponentUpdater = { isMounted: function(component) { @@ -2368,6 +2275,7 @@ function mountClassInstance( instance.props = newProps; instance.state = workInProgress.memoizedState; instance.refs = emptyRefsObject; + initializeUpdateQueue(workInProgress); var contextType = ctor.contextType; "object" === typeof contextType && null !== contextType ? (instance.context = readContext(contextType)) @@ -2375,16 +2283,8 @@ function mountClassInstance( ? previousContext : contextStackCursor.current), (instance.context = getMaskedContext(workInProgress, contextType))); - contextType = workInProgress.updateQueue; - null !== contextType && - (processUpdateQueue( - workInProgress, - contextType, - newProps, - instance, - renderExpirationTime - ), - (instance.state = workInProgress.memoizedState)); + processUpdateQueue(workInProgress, newProps, instance, renderExpirationTime); + instance.state = workInProgress.memoizedState; contextType = ctor.getDerivedStateFromProps; "function" === typeof contextType && (applyDerivedStateFromProps(workInProgress, ctor, contextType, newProps), @@ -2400,16 +2300,13 @@ function mountClassInstance( instance.UNSAFE_componentWillMount(), ctor !== instance.state && classComponentUpdater.enqueueReplaceState(instance, instance.state, null), - (contextType = workInProgress.updateQueue), - null !== contextType && - (processUpdateQueue( - workInProgress, - contextType, - newProps, - instance, - renderExpirationTime - ), - (instance.state = workInProgress.memoizedState))); + processUpdateQueue( + workInProgress, + newProps, + instance, + renderExpirationTime + ), + (instance.state = workInProgress.memoizedState)); "function" === typeof instance.componentDidMount && (workInProgress.effectTag |= 4); } @@ -2971,39 +2868,50 @@ function ChildReconciler(shouldTrackSideEffects) { null !== isUnkeyedTopLevelFragment; ) { - if (isUnkeyedTopLevelFragment.key === isObject) - if ( - 7 === isUnkeyedTopLevelFragment.tag - ? newChild.type === REACT_FRAGMENT_TYPE - : isUnkeyedTopLevelFragment.elementType === newChild.type - ) { - deleteRemainingChildren( - returnFiber, - isUnkeyedTopLevelFragment.sibling - ); - currentFirstChild = useFiber( - isUnkeyedTopLevelFragment, - newChild.type === REACT_FRAGMENT_TYPE - ? newChild.props.children - : newChild.props, - expirationTime - ); - currentFirstChild.ref = coerceRef( - returnFiber, - isUnkeyedTopLevelFragment, - newChild - ); - currentFirstChild.return = returnFiber; - returnFiber = currentFirstChild; - break a; - } else { - deleteRemainingChildren( - returnFiber, - isUnkeyedTopLevelFragment - ); - break; + if (isUnkeyedTopLevelFragment.key === isObject) { + switch (isUnkeyedTopLevelFragment.tag) { + case 7: + if (newChild.type === REACT_FRAGMENT_TYPE) { + deleteRemainingChildren( + returnFiber, + isUnkeyedTopLevelFragment.sibling + ); + currentFirstChild = useFiber( + isUnkeyedTopLevelFragment, + newChild.props.children, + expirationTime + ); + currentFirstChild.return = returnFiber; + returnFiber = currentFirstChild; + break a; + } + break; + default: + if ( + isUnkeyedTopLevelFragment.elementType === newChild.type + ) { + deleteRemainingChildren( + returnFiber, + isUnkeyedTopLevelFragment.sibling + ); + currentFirstChild = useFiber( + isUnkeyedTopLevelFragment, + newChild.props, + expirationTime + ); + currentFirstChild.ref = coerceRef( + returnFiber, + isUnkeyedTopLevelFragment, + newChild + ); + currentFirstChild.return = returnFiber; + returnFiber = currentFirstChild; + break a; + } } - else deleteChild(returnFiber, isUnkeyedTopLevelFragment); + deleteRemainingChildren(returnFiber, isUnkeyedTopLevelFragment); + break; + } else deleteChild(returnFiber, isUnkeyedTopLevelFragment); isUnkeyedTopLevelFragment = isUnkeyedTopLevelFragment.sibling; } newChild.type === REACT_FRAGMENT_TYPE @@ -3201,7 +3109,7 @@ function findFirstSuspended(row) { } return null; } -function createResponderListener(responder, props) { +function createDeprecatedResponderListener(responder, props) { return { responder: responder, props: props }; } var ReactCurrentDispatcher$1 = ReactSharedInternals.ReactCurrentDispatcher, @@ -3209,13 +3117,7 @@ var ReactCurrentDispatcher$1 = ReactSharedInternals.ReactCurrentDispatcher, renderExpirationTime$1 = 0, currentlyRenderingFiber$1 = null, currentHook = null, - nextCurrentHook = null, - firstWorkInProgressHook = null, workInProgressHook = null, - nextWorkInProgressHook = null, - remainingExpirationTime = 0, - componentUpdateQueue = null, - sideEffectTag = 0, didScheduleRenderPhaseUpdate = !1, renderPhaseUpdates = null, numberOfReRenders = 0; @@ -3235,53 +3137,45 @@ function renderWithHooks( workInProgress, Component, props, - refOrContext, + secondArg, nextRenderExpirationTime ) { renderExpirationTime$1 = nextRenderExpirationTime; currentlyRenderingFiber$1 = workInProgress; - nextCurrentHook = null !== current ? current.memoizedState : null; + workInProgress.memoizedState = null; + workInProgress.updateQueue = null; + workInProgress.expirationTime = 0; ReactCurrentDispatcher$1.current = - null === nextCurrentHook ? HooksDispatcherOnMount : HooksDispatcherOnUpdate; - workInProgress = Component(props, refOrContext); + null === current || null === current.memoizedState + ? HooksDispatcherOnMount + : HooksDispatcherOnUpdate; + current = Component(props, secondArg); if (didScheduleRenderPhaseUpdate) { do (didScheduleRenderPhaseUpdate = !1), (numberOfReRenders += 1), - (nextCurrentHook = null !== current ? current.memoizedState : null), - (nextWorkInProgressHook = firstWorkInProgressHook), - (componentUpdateQueue = workInProgressHook = currentHook = null), + (workInProgressHook = currentHook = null), + (workInProgress.updateQueue = null), (ReactCurrentDispatcher$1.current = HooksDispatcherOnUpdate), - (workInProgress = Component(props, refOrContext)); + (current = Component(props, secondArg)); while (didScheduleRenderPhaseUpdate); renderPhaseUpdates = null; numberOfReRenders = 0; } ReactCurrentDispatcher$1.current = ContextOnlyDispatcher; - current = currentlyRenderingFiber$1; - current.memoizedState = firstWorkInProgressHook; - current.expirationTime = remainingExpirationTime; - current.updateQueue = componentUpdateQueue; - current.effectTag |= sideEffectTag; - current = null !== currentHook && null !== currentHook.next; + workInProgress = null !== currentHook && null !== currentHook.next; renderExpirationTime$1 = 0; - nextWorkInProgressHook = workInProgressHook = firstWorkInProgressHook = nextCurrentHook = currentHook = currentlyRenderingFiber$1 = null; - remainingExpirationTime = 0; - componentUpdateQueue = null; - sideEffectTag = 0; - if (current) + workInProgressHook = currentHook = currentlyRenderingFiber$1 = null; + if (workInProgress) throw Error( "Rendered fewer hooks than expected. This may be caused by an accidental early return statement." ); - return workInProgress; + return current; } function resetHooks() { ReactCurrentDispatcher$1.current = ContextOnlyDispatcher; renderExpirationTime$1 = 0; - nextWorkInProgressHook = workInProgressHook = firstWorkInProgressHook = nextCurrentHook = currentHook = currentlyRenderingFiber$1 = null; - remainingExpirationTime = 0; - componentUpdateQueue = null; - sideEffectTag = 0; + workInProgressHook = currentHook = currentlyRenderingFiber$1 = null; didScheduleRenderPhaseUpdate = !1; renderPhaseUpdates = null; numberOfReRenders = 0; @@ -3290,37 +3184,42 @@ function mountWorkInProgressHook() { var hook = { memoizedState: null, baseState: null, + baseQueue: null, queue: null, - baseUpdate: null, next: null }; null === workInProgressHook - ? (firstWorkInProgressHook = workInProgressHook = hook) + ? (currentlyRenderingFiber$1.memoizedState = workInProgressHook = hook) : (workInProgressHook = workInProgressHook.next = hook); return workInProgressHook; } function updateWorkInProgressHook() { + if (null === currentHook) { + var nextCurrentHook = currentlyRenderingFiber$1.alternate; + nextCurrentHook = + null !== nextCurrentHook ? nextCurrentHook.memoizedState : null; + } else nextCurrentHook = currentHook.next; + var nextWorkInProgressHook = + null === workInProgressHook + ? currentlyRenderingFiber$1.memoizedState + : workInProgressHook.next; if (null !== nextWorkInProgressHook) (workInProgressHook = nextWorkInProgressHook), - (nextWorkInProgressHook = workInProgressHook.next), - (currentHook = nextCurrentHook), - (nextCurrentHook = null !== currentHook ? currentHook.next : null); + (currentHook = nextCurrentHook); else { if (null === nextCurrentHook) throw Error("Rendered more hooks than during the previous render."); currentHook = nextCurrentHook; - var newHook = { + nextCurrentHook = { memoizedState: currentHook.memoizedState, baseState: currentHook.baseState, + baseQueue: currentHook.baseQueue, queue: currentHook.queue, - baseUpdate: currentHook.baseUpdate, next: null }; - workInProgressHook = - null === workInProgressHook - ? (firstWorkInProgressHook = newHook) - : (workInProgressHook.next = newHook); - nextCurrentHook = currentHook.next; + null === workInProgressHook + ? (currentlyRenderingFiber$1.memoizedState = workInProgressHook = nextCurrentHook) + : (workInProgressHook = workInProgressHook.next = nextCurrentHook); } return workInProgressHook; } @@ -3348,51 +3247,75 @@ function updateReducer(reducer) { while (null !== firstRenderPhaseUpdate); is$1(newState, hook.memoizedState) || (didReceiveUpdate = !0); hook.memoizedState = newState; - hook.baseUpdate === queue.last && (hook.baseState = newState); + null === hook.baseQueue && (hook.baseState = newState); queue.lastRenderedState = newState; return [newState, _dispatch]; } } return [hook.memoizedState, _dispatch]; } - _dispatch = queue.last; - var baseUpdate = hook.baseUpdate; - newState = hook.baseState; - null !== baseUpdate - ? (null !== _dispatch && (_dispatch.next = null), - (_dispatch = baseUpdate.next)) - : (_dispatch = null !== _dispatch ? _dispatch.next : null); + newState = currentHook; + _dispatch = newState.baseQueue; + firstRenderPhaseUpdate = queue.pending; + if (null !== firstRenderPhaseUpdate) { + if (null !== _dispatch) { + var baseFirst = _dispatch.next; + _dispatch.next = firstRenderPhaseUpdate.next; + firstRenderPhaseUpdate.next = baseFirst; + } + newState.baseQueue = _dispatch = firstRenderPhaseUpdate; + queue.pending = null; + } if (null !== _dispatch) { - var newBaseUpdate = (firstRenderPhaseUpdate = null), - _update = _dispatch, - didSkip = !1; + _dispatch = _dispatch.next; + newState = newState.baseState; + var newBaseQueueLast = (baseFirst = firstRenderPhaseUpdate = null), + _update = _dispatch; do { var updateExpirationTime = _update.expirationTime; - updateExpirationTime < renderExpirationTime$1 - ? (didSkip || - ((didSkip = !0), - (newBaseUpdate = baseUpdate), - (firstRenderPhaseUpdate = newState)), - updateExpirationTime > remainingExpirationTime && - ((remainingExpirationTime = updateExpirationTime), - markUnprocessedUpdateTime(remainingExpirationTime))) - : (markRenderEventTimeAndConfig( + if (updateExpirationTime < renderExpirationTime$1) { + var clone = { + expirationTime: _update.expirationTime, + suspenseConfig: _update.suspenseConfig, + action: _update.action, + eagerReducer: _update.eagerReducer, + eagerState: _update.eagerState, + next: null + }; + null === newBaseQueueLast + ? ((baseFirst = newBaseQueueLast = clone), + (firstRenderPhaseUpdate = newState)) + : (newBaseQueueLast = newBaseQueueLast.next = clone); + updateExpirationTime > currentlyRenderingFiber$1.expirationTime && + ((currentlyRenderingFiber$1.expirationTime = updateExpirationTime), + markUnprocessedUpdateTime(updateExpirationTime)); + } else + null !== newBaseQueueLast && + (newBaseQueueLast = newBaseQueueLast.next = { + expirationTime: 1073741823, + suspenseConfig: _update.suspenseConfig, + action: _update.action, + eagerReducer: _update.eagerReducer, + eagerState: _update.eagerState, + next: null + }), + markRenderEventTimeAndConfig( updateExpirationTime, _update.suspenseConfig ), (newState = _update.eagerReducer === reducer ? _update.eagerState - : reducer(newState, _update.action))); - baseUpdate = _update; + : reducer(newState, _update.action)); _update = _update.next; } while (null !== _update && _update !== _dispatch); - didSkip || - ((newBaseUpdate = baseUpdate), (firstRenderPhaseUpdate = newState)); + null === newBaseQueueLast + ? (firstRenderPhaseUpdate = newState) + : (newBaseQueueLast.next = baseFirst); is$1(newState, hook.memoizedState) || (didReceiveUpdate = !0); hook.memoizedState = newState; - hook.baseUpdate = newBaseUpdate; hook.baseState = firstRenderPhaseUpdate; + hook.baseQueue = newBaseQueueLast; queue.lastRenderedState = newState; } return [hook.memoizedState, queue.dispatch]; @@ -3402,7 +3325,7 @@ function mountState(initialState) { "function" === typeof initialState && (initialState = initialState()); hook.memoizedState = hook.baseState = initialState; initialState = hook.queue = { - last: null, + pending: null, dispatch: null, lastRenderedReducer: basicStateReducer, lastRenderedState: initialState @@ -3419,21 +3342,23 @@ function updateState(initialState) { } function pushEffect(tag, create, destroy, deps) { tag = { tag: tag, create: create, destroy: destroy, deps: deps, next: null }; - null === componentUpdateQueue - ? ((componentUpdateQueue = { lastEffect: null }), - (componentUpdateQueue.lastEffect = tag.next = tag)) - : ((create = componentUpdateQueue.lastEffect), - null === create - ? (componentUpdateQueue.lastEffect = tag.next = tag) - : ((destroy = create.next), - (create.next = tag), - (tag.next = destroy), - (componentUpdateQueue.lastEffect = tag))); + create = currentlyRenderingFiber$1.updateQueue; + null === create + ? ((create = { lastEffect: null }), + (currentlyRenderingFiber$1.updateQueue = create), + (create.lastEffect = tag.next = tag)) + : ((destroy = create.lastEffect), + null === destroy + ? (create.lastEffect = tag.next = tag) + : ((deps = destroy.next), + (destroy.next = tag), + (tag.next = deps), + (create.lastEffect = tag))); return tag; } function mountEffectImpl(fiberEffectTag, hookEffectTag, create, deps) { var hook = mountWorkInProgressHook(); - sideEffectTag |= fiberEffectTag; + currentlyRenderingFiber$1.effectTag |= fiberEffectTag; hook.memoizedState = pushEffect( hookEffectTag, create, @@ -3453,7 +3378,7 @@ function updateEffectImpl(fiberEffectTag, hookEffectTag, create, deps) { return; } } - sideEffectTag |= fiberEffectTag; + currentlyRenderingFiber$1.effectTag |= fiberEffectTag; hook.memoizedState = pushEffect(hookEffectTag, create, destroy, deps); } function mountEffect(create, deps) { @@ -3501,6 +3426,21 @@ function updateCallback(callback, deps) { hook.memoizedState = [callback, deps]; return callback; } +function startTransition(setPending, config, callback) { + var priorityLevel = getCurrentPriorityLevel(); + runWithPriority(98 > priorityLevel ? 98 : priorityLevel, function() { + setPending(!0); + }); + runWithPriority(97 < priorityLevel ? 97 : priorityLevel, function() { + var previousConfig = ReactCurrentBatchConfig$1.suspense; + ReactCurrentBatchConfig$1.suspense = void 0 === config ? null : config; + try { + setPending(!1), callback(); + } finally { + ReactCurrentBatchConfig$1.suspense = previousConfig; + } + }); +} function dispatchAction(fiber, queue, action) { if (!(25 > numberOfReRenders)) throw Error( @@ -3542,14 +3482,11 @@ function dispatchAction(fiber, queue, action) { eagerState: null, next: null }; - var last = queue.last; - if (null === last) suspenseConfig.next = suspenseConfig; - else { - var first = last.next; - null !== first && (suspenseConfig.next = first); - last.next = suspenseConfig; - } - queue.last = suspenseConfig; + var pending = queue.pending; + null === pending + ? (suspenseConfig.next = suspenseConfig) + : ((suspenseConfig.next = pending.next), (pending.next = suspenseConfig)); + queue.pending = suspenseConfig; if ( 0 === fiber.expirationTime && (null === alternate || 0 === alternate.expirationTime) && @@ -3612,7 +3549,7 @@ var ContextOnlyDispatcher = { initialArg = void 0 !== init ? init(initialArg) : initialArg; hook.memoizedState = hook.baseState = initialArg; reducer = hook.queue = { - last: null, + pending: null, dispatch: null, lastRenderedReducer: reducer, lastRenderedState: initialArg @@ -3631,23 +3568,21 @@ var ContextOnlyDispatcher = { }, useState: mountState, useDebugValue: mountDebugValue, - useResponder: createResponderListener, + useResponder: createDeprecatedResponderListener, useDeferredValue: function(value, config) { var _mountState = mountState(value), prevValue = _mountState[0], setValue = _mountState[1]; mountEffect( function() { - Scheduler.unstable_next(function() { - var previousConfig = ReactCurrentBatchConfig$1.suspense; - ReactCurrentBatchConfig$1.suspense = - void 0 === config ? null : config; - try { - setValue(value); - } finally { - ReactCurrentBatchConfig$1.suspense = previousConfig; - } - }); + var previousConfig = ReactCurrentBatchConfig$1.suspense; + ReactCurrentBatchConfig$1.suspense = + void 0 === config ? null : config; + try { + setValue(value); + } finally { + ReactCurrentBatchConfig$1.suspense = previousConfig; + } }, [value, config] ); @@ -3655,25 +3590,13 @@ var ContextOnlyDispatcher = { }, useTransition: function(config) { var _mountState2 = mountState(!1), - isPending = _mountState2[0], - setPending = _mountState2[1]; + isPending = _mountState2[0]; + _mountState2 = _mountState2[1]; return [ - mountCallback( - function(callback) { - setPending(!0); - Scheduler.unstable_next(function() { - var previousConfig = ReactCurrentBatchConfig$1.suspense; - ReactCurrentBatchConfig$1.suspense = - void 0 === config ? null : config; - try { - setPending(!1), callback(); - } finally { - ReactCurrentBatchConfig$1.suspense = previousConfig; - } - }); - }, - [config, isPending] - ), + mountCallback(startTransition.bind(null, _mountState2, config), [ + _mountState2, + config + ]), isPending ]; } @@ -3715,23 +3638,21 @@ var ContextOnlyDispatcher = { }, useState: updateState, useDebugValue: mountDebugValue, - useResponder: createResponderListener, + useResponder: createDeprecatedResponderListener, useDeferredValue: function(value, config) { var _updateState = updateState(value), prevValue = _updateState[0], setValue = _updateState[1]; updateEffect( function() { - Scheduler.unstable_next(function() { - var previousConfig = ReactCurrentBatchConfig$1.suspense; - ReactCurrentBatchConfig$1.suspense = - void 0 === config ? null : config; - try { - setValue(value); - } finally { - ReactCurrentBatchConfig$1.suspense = previousConfig; - } - }); + var previousConfig = ReactCurrentBatchConfig$1.suspense; + ReactCurrentBatchConfig$1.suspense = + void 0 === config ? null : config; + try { + setValue(value); + } finally { + ReactCurrentBatchConfig$1.suspense = previousConfig; + } }, [value, config] ); @@ -3739,25 +3660,13 @@ var ContextOnlyDispatcher = { }, useTransition: function(config) { var _updateState2 = updateState(!1), - isPending = _updateState2[0], - setPending = _updateState2[1]; + isPending = _updateState2[0]; + _updateState2 = _updateState2[1]; return [ - updateCallback( - function(callback) { - setPending(!0); - Scheduler.unstable_next(function() { - var previousConfig = ReactCurrentBatchConfig$1.suspense; - ReactCurrentBatchConfig$1.suspense = - void 0 === config ? null : config; - try { - setPending(!1), callback(); - } finally { - ReactCurrentBatchConfig$1.suspense = previousConfig; - } - }); - }, - [config, isPending] - ), + updateCallback(startTransition.bind(null, _updateState2, config), [ + _updateState2, + config + ]), isPending ]; } @@ -4071,17 +3980,14 @@ function updateClassComponent( )); hasForceUpdate = !1; var oldState = workInProgress.memoizedState; - oldContext = instance.state = oldState; - var updateQueue = workInProgress.updateQueue; - null !== updateQueue && - (processUpdateQueue( - workInProgress, - updateQueue, - nextProps, - instance, - renderExpirationTime - ), - (oldContext = workInProgress.memoizedState)); + instance.state = oldState; + processUpdateQueue( + workInProgress, + nextProps, + instance, + renderExpirationTime + ); + oldContext = workInProgress.memoizedState; oldProps !== nextProps || oldState !== oldContext || didPerformWorkStackCursor.current || @@ -4127,6 +4033,7 @@ function updateClassComponent( (nextProps = !1)); } else (instance = workInProgress.stateNode), + cloneUpdateQueue(current$$1, workInProgress), (oldProps = workInProgress.memoizedProps), (instance.props = workInProgress.type === workInProgress.elementType @@ -4155,17 +4062,14 @@ function updateClassComponent( )), (hasForceUpdate = !1), (oldContext = workInProgress.memoizedState), - (oldState = instance.state = oldContext), - (updateQueue = workInProgress.updateQueue), - null !== updateQueue && - (processUpdateQueue( - workInProgress, - updateQueue, - nextProps, - instance, - renderExpirationTime - ), - (oldState = workInProgress.memoizedState)), + (instance.state = oldContext), + processUpdateQueue( + workInProgress, + nextProps, + instance, + renderExpirationTime + ), + (oldState = workInProgress.memoizedState), oldProps !== nextProps || oldContext !== oldState || didPerformWorkStackCursor.current || @@ -4467,6 +4371,7 @@ function initSuspenseListRenderState( ? (workInProgress.memoizedState = { isBackwards: isBackwards, rendering: null, + renderingStartTime: 0, last: lastContentRow, tail: tail, tailExpiration: 0, @@ -4475,6 +4380,7 @@ function initSuspenseListRenderState( }) : ((renderState.isBackwards = isBackwards), (renderState.rendering = null), + (renderState.renderingStartTime = 0), (renderState.last = lastContentRow), (renderState.tail = tail), (renderState.tailExpiration = 0), @@ -4801,16 +4707,17 @@ updateHostComponent$1 = function(current, workInProgress, type, newProps) { } }; 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.effectTag |= 4)); + oldText !== newText + ? ((current = requiredContext(rootInstanceStackCursor.current)), + (oldText = requiredContext(contextStackCursor$1.current)), + (workInProgress.stateNode = createTextInstance( + newText, + current, + oldText, + workInProgress + )), + (workInProgress.effectTag |= 4)) + : (workInProgress.stateNode = current.stateNode); }; function cutOffTailIfNeeded(renderState, hasRenderedATailFallback) { switch (renderState.tailMode) { @@ -4836,51 +4743,361 @@ function cutOffTailIfNeeded(renderState, hasRenderedATailFallback) { : (_lastTailNode.sibling = null); } } -function unwindWork(workInProgress) { +function completeWork(current, workInProgress, renderExpirationTime$jscomp$0) { + 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 null; case 1: - isContextProvider(workInProgress.type) && popContext(workInProgress); - var effectTag = workInProgress.effectTag; - return effectTag & 4096 - ? ((workInProgress.effectTag = (effectTag & -4097) | 64), - workInProgress) - : null; + return ( + isContextProvider(workInProgress.type) && popContext(workInProgress), + null + ); case 3: - popHostContainer(workInProgress); - popTopLevelContextObject(workInProgress); - effectTag = workInProgress.effectTag; - if (0 !== (effectTag & 64)) - throw Error( - "The root failed to unmount after an error. This is likely a bug in React. Please file an issue." - ); - workInProgress.effectTag = (effectTag & -4097) | 64; - return workInProgress; - case 5: - return popHostContext(workInProgress), null; - case 13: return ( - pop(suspenseStackCursor, workInProgress), - (effectTag = workInProgress.effectTag), - effectTag & 4096 - ? ((workInProgress.effectTag = (effectTag & -4097) | 64), - workInProgress) - : null + popHostContainer(workInProgress), + popTopLevelContextObject(workInProgress), + (current = workInProgress.stateNode), + current.pendingContext && + ((current.context = current.pendingContext), + (current.pendingContext = null)), + updateHostContainer(workInProgress), + null ); - case 19: - return pop(suspenseStackCursor, workInProgress), null; - case 4: - return popHostContainer(workInProgress), null; - case 10: - return popProvider(workInProgress), null; - default: + case 5: + popHostContext(workInProgress); + var rootContainerInstance = requiredContext( + rootInstanceStackCursor.current + ); + renderExpirationTime$jscomp$0 = workInProgress.type; + if (null !== current && null != workInProgress.stateNode) + updateHostComponent$1( + current, + workInProgress, + renderExpirationTime$jscomp$0, + newProps, + rootContainerInstance + ), + current.ref !== workInProgress.ref && + (workInProgress.effectTag |= 128); + 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." + ); + return null; + } + requiredContext(contextStackCursor$1.current); + current = nextReactTag; + nextReactTag += 2; + renderExpirationTime$jscomp$0 = getViewConfigForType( + renderExpirationTime$jscomp$0 + ); + var updatePayload = diffProperties( + null, + emptyObject, + newProps, + renderExpirationTime$jscomp$0.validAttributes + ); + rootContainerInstance = createNode( + current, + renderExpirationTime$jscomp$0.uiViewClassName, + rootContainerInstance, + updatePayload, + workInProgress + ); + current = new ReactFabricHostComponent( + current, + renderExpirationTime$jscomp$0, + newProps, + workInProgress + ); + current = { node: rootContainerInstance, canonical: current }; + appendAllChildren(current, workInProgress, !1, !1); + workInProgress.stateNode = current; + null !== workInProgress.ref && (workInProgress.effectTag |= 128); + } return null; - } -} -function createCapturedValue(value, source) { - return { - value: value, - source: source, - stack: getStackByFiberInDevAndProd(source) + 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); + rootContainerInstance = requiredContext(contextStackCursor$1.current); + workInProgress.stateNode = createTextInstance( + newProps, + current, + rootContainerInstance, + workInProgress + ); + } + return null; + case 13: + pop(suspenseStackCursor, workInProgress); + newProps = workInProgress.memoizedState; + if (0 !== (workInProgress.effectTag & 64)) + return ( + (workInProgress.expirationTime = renderExpirationTime$jscomp$0), + workInProgress + ); + newProps = null !== newProps; + rootContainerInstance = !1; + null !== current && + ((renderExpirationTime$jscomp$0 = current.memoizedState), + (rootContainerInstance = null !== renderExpirationTime$jscomp$0), + newProps || + null === renderExpirationTime$jscomp$0 || + ((renderExpirationTime$jscomp$0 = current.child.sibling), + null !== renderExpirationTime$jscomp$0 && + ((updatePayload = workInProgress.firstEffect), + null !== updatePayload + ? ((workInProgress.firstEffect = renderExpirationTime$jscomp$0), + (renderExpirationTime$jscomp$0.nextEffect = updatePayload)) + : ((workInProgress.firstEffect = workInProgress.lastEffect = renderExpirationTime$jscomp$0), + (renderExpirationTime$jscomp$0.nextEffect = null)), + (renderExpirationTime$jscomp$0.effectTag = 8)))); + if (newProps && !rootContainerInstance && 0 !== (workInProgress.mode & 2)) + if ( + (null === current && + !0 !== workInProgress.memoizedProps.unstable_avoidThisFallback) || + 0 !== (suspenseStackCursor.current & 1) + ) + workInProgressRootExitStatus === RootIncomplete && + (workInProgressRootExitStatus = RootSuspended); + else { + if ( + workInProgressRootExitStatus === RootIncomplete || + workInProgressRootExitStatus === RootSuspended + ) + workInProgressRootExitStatus = RootSuspendedWithDelay; + 0 !== workInProgressRootNextUnprocessedUpdateTime && + null !== workInProgressRoot && + (markRootSuspendedAtTime(workInProgressRoot, renderExpirationTime), + markRootUpdatedAtTime( + workInProgressRoot, + workInProgressRootNextUnprocessedUpdateTime + )); + } + newProps && (workInProgress.effectTag |= 4); + return null; + case 4: + return ( + popHostContainer(workInProgress), + updateHostContainer(workInProgress), + null + ); + case 10: + return popProvider(workInProgress), null; + case 17: + return ( + isContextProvider(workInProgress.type) && popContext(workInProgress), + null + ); + case 19: + pop(suspenseStackCursor, workInProgress); + newProps = workInProgress.memoizedState; + if (null === newProps) return null; + rootContainerInstance = 0 !== (workInProgress.effectTag & 64); + updatePayload = newProps.rendering; + if (null === updatePayload) + if (rootContainerInstance) cutOffTailIfNeeded(newProps, !1); + else { + if ( + workInProgressRootExitStatus !== RootIncomplete || + (null !== current && 0 !== (current.effectTag & 64)) + ) + for (current = workInProgress.child; null !== current; ) { + updatePayload = findFirstSuspended(current); + if (null !== updatePayload) { + workInProgress.effectTag |= 64; + cutOffTailIfNeeded(newProps, !1); + current = updatePayload.updateQueue; + null !== current && + ((workInProgress.updateQueue = current), + (workInProgress.effectTag |= 4)); + null === newProps.lastEffect && + (workInProgress.firstEffect = null); + workInProgress.lastEffect = newProps.lastEffect; + current = renderExpirationTime$jscomp$0; + for (newProps = workInProgress.child; null !== newProps; ) + (rootContainerInstance = newProps), + (renderExpirationTime$jscomp$0 = current), + (rootContainerInstance.effectTag &= 2), + (rootContainerInstance.nextEffect = null), + (rootContainerInstance.firstEffect = null), + (rootContainerInstance.lastEffect = null), + (updatePayload = rootContainerInstance.alternate), + null === updatePayload + ? ((rootContainerInstance.childExpirationTime = 0), + (rootContainerInstance.expirationTime = renderExpirationTime$jscomp$0), + (rootContainerInstance.child = null), + (rootContainerInstance.memoizedProps = null), + (rootContainerInstance.memoizedState = null), + (rootContainerInstance.updateQueue = null), + (rootContainerInstance.dependencies = null)) + : ((rootContainerInstance.childExpirationTime = + updatePayload.childExpirationTime), + (rootContainerInstance.expirationTime = + updatePayload.expirationTime), + (rootContainerInstance.child = updatePayload.child), + (rootContainerInstance.memoizedProps = + updatePayload.memoizedProps), + (rootContainerInstance.memoizedState = + updatePayload.memoizedState), + (rootContainerInstance.updateQueue = + updatePayload.updateQueue), + (renderExpirationTime$jscomp$0 = + updatePayload.dependencies), + (rootContainerInstance.dependencies = + null === renderExpirationTime$jscomp$0 + ? null + : { + expirationTime: + renderExpirationTime$jscomp$0.expirationTime, + firstContext: + renderExpirationTime$jscomp$0.firstContext, + responders: + renderExpirationTime$jscomp$0.responders + })), + (newProps = newProps.sibling); + push( + suspenseStackCursor, + (suspenseStackCursor.current & 1) | 2, + workInProgress + ); + return workInProgress.child; + } + current = current.sibling; + } + } + else { + if (!rootContainerInstance) + if ( + ((current = findFirstSuspended(updatePayload)), null !== current) + ) { + if ( + ((workInProgress.effectTag |= 64), + (rootContainerInstance = !0), + (current = current.updateQueue), + null !== current && + ((workInProgress.updateQueue = current), + (workInProgress.effectTag |= 4)), + cutOffTailIfNeeded(newProps, !0), + null === newProps.tail && + "hidden" === newProps.tailMode && + !updatePayload.alternate) + ) + return ( + (workInProgress = workInProgress.lastEffect = + newProps.lastEffect), + null !== workInProgress && (workInProgress.nextEffect = null), + null + ); + } else + 2 * now() - newProps.renderingStartTime > newProps.tailExpiration && + 1 < renderExpirationTime$jscomp$0 && + ((workInProgress.effectTag |= 64), + (rootContainerInstance = !0), + cutOffTailIfNeeded(newProps, !1), + (workInProgress.expirationTime = workInProgress.childExpirationTime = + renderExpirationTime$jscomp$0 - 1)); + newProps.isBackwards + ? ((updatePayload.sibling = workInProgress.child), + (workInProgress.child = updatePayload)) + : ((current = newProps.last), + null !== current + ? (current.sibling = updatePayload) + : (workInProgress.child = updatePayload), + (newProps.last = updatePayload)); + } + return null !== newProps.tail + ? (0 === newProps.tailExpiration && + (newProps.tailExpiration = now() + 500), + (current = newProps.tail), + (newProps.rendering = current), + (newProps.tail = current.sibling), + (newProps.lastEffect = workInProgress.lastEffect), + (newProps.renderingStartTime = now()), + (current.sibling = null), + (newProps = suspenseStackCursor.current), + push( + suspenseStackCursor, + rootContainerInstance ? (newProps & 1) | 2 : newProps & 1, + workInProgress + ), + current) + : null; + } + throw 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) { + switch (workInProgress.tag) { + case 1: + isContextProvider(workInProgress.type) && popContext(workInProgress); + var effectTag = workInProgress.effectTag; + return effectTag & 4096 + ? ((workInProgress.effectTag = (effectTag & -4097) | 64), + workInProgress) + : null; + case 3: + popHostContainer(workInProgress); + popTopLevelContextObject(workInProgress); + effectTag = workInProgress.effectTag; + if (0 !== (effectTag & 64)) + throw Error( + "The root failed to unmount after an error. This is likely a bug in React. Please file an issue." + ); + workInProgress.effectTag = (effectTag & -4097) | 64; + return workInProgress; + case 5: + return popHostContext(workInProgress), null; + case 13: + return ( + pop(suspenseStackCursor, workInProgress), + (effectTag = workInProgress.effectTag), + effectTag & 4096 + ? ((workInProgress.effectTag = (effectTag & -4097) | 64), + workInProgress) + : null + ); + case 19: + return pop(suspenseStackCursor, workInProgress), null; + case 4: + return popHostContainer(workInProgress), null; + case 10: + return popProvider(workInProgress), null; + default: + return null; + } +} +function createCapturedValue(value, source) { + return { + value: value, + source: source, + stack: getStackByFiberInDevAndProd(source) }; } if ( @@ -4951,8 +5168,9 @@ function commitBeforeMutationLifeCycles(current$$1, finishedWork) { case 0: case 11: case 15: + case 22: commitHookEffectList(2, 0, finishedWork); - break; + return; case 1: if (finishedWork.effectTag & 256 && null !== current$$1) { var prevProps = current$$1.memoizedProps, @@ -4966,18 +5184,17 @@ function commitBeforeMutationLifeCycles(current$$1, finishedWork) { ); current$$1.__reactInternalSnapshotBeforeUpdate = finishedWork; } - break; + return; case 3: case 5: case 6: case 4: case 17: - 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." - ); + return; } + throw Error( + "This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue." + ); } function commitHookEffectList(unmountTag, mountTag, finishedWork) { finishedWork = finishedWork.updateQueue; @@ -4996,6 +5213,90 @@ function commitHookEffectList(unmountTag, mountTag, finishedWork) { } while (effect !== finishedWork); } } +function commitLifeCycles( + finishedRoot, + current$$1, + finishedWork, + committedExpirationTime +) { + switch (finishedWork.tag) { + case 0: + case 11: + case 15: + case 22: + commitHookEffectList(16, 32, finishedWork); + return; + case 1: + finishedRoot = finishedWork.stateNode; + if (finishedWork.effectTag & 4) + if (null === current$$1) finishedRoot.componentDidMount(); + else { + var prevProps = + finishedWork.elementType === finishedWork.type + ? current$$1.memoizedProps + : resolveDefaultProps( + finishedWork.type, + current$$1.memoizedProps + ); + finishedRoot.componentDidUpdate( + prevProps, + current$$1.memoizedState, + finishedRoot.__reactInternalSnapshotBeforeUpdate + ); + } + current$$1 = finishedWork.updateQueue; + null !== current$$1 && + commitUpdateQueue( + finishedWork, + current$$1, + finishedRoot, + committedExpirationTime + ); + return; + case 3: + current$$1 = finishedWork.updateQueue; + if (null !== current$$1) { + finishedRoot = null; + if (null !== finishedWork.child) + switch (finishedWork.child.tag) { + case 5: + finishedRoot = finishedWork.child.stateNode.canonical; + break; + case 1: + finishedRoot = finishedWork.child.stateNode; + } + commitUpdateQueue( + finishedWork, + current$$1, + finishedRoot, + committedExpirationTime + ); + } + return; + case 5: + if (null === current$$1 && finishedWork.effectTag & 4) + throw Error( + "The current renderer does not support mutation. This error is likely caused by a bug in React. Please file an issue." + ); + return; + case 6: + return; + case 4: + return; + case 12: + return; + case 13: + return; + case 19: + case 17: + case 20: + case 21: + return; + } + throw Error( + "This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue." + ); +} function commitUnmount(finishedRoot, current$$1$jscomp$0, renderPriorityLevel) { "function" === typeof onCommitFiberUnmount && onCommitFiberUnmount(current$$1$jscomp$0); @@ -5004,13 +5305,14 @@ function commitUnmount(finishedRoot, current$$1$jscomp$0, renderPriorityLevel) { case 11: case 14: case 15: + case 22: finishedRoot = current$$1$jscomp$0.updateQueue; if ( null !== finishedRoot && ((finishedRoot = finishedRoot.lastEffect), null !== finishedRoot) ) { var firstEffect = finishedRoot.next; - runWithPriority$1( + runWithPriority( 97 < renderPriorityLevel ? 97 : renderPriorityLevel, function() { var effect = firstEffect; @@ -5058,6 +5360,7 @@ function detachFiber(current$$1) { current$$1.lastEffect = null; current$$1.pendingProps = null; current$$1.memoizedProps = null; + current$$1.stateNode = null; null !== alternate && detachFiber(alternate); } function commitWork(current$$1, finishedWork) { @@ -5066,6 +5369,7 @@ function commitWork(current$$1, finishedWork) { case 11: case 14: case 15: + case 22: commitHookEffectList(4, 8, finishedWork); return; case 12: @@ -5079,19 +5383,20 @@ function commitWork(current$$1, finishedWork) { attachSuspenseRetryListeners(finishedWork); return; } - a: switch (finishedWork.tag) { - case 1: - case 5: - case 6: - case 20: - break a; - case 3: - case 4: - break a; - 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." - ); + a: { + switch (finishedWork.tag) { + case 1: + case 5: + case 6: + case 20: + break a; + case 3: + case 4: + break a; + } + throw Error( + "This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue." + ); } } function attachSuspenseRetryListeners(finishedWork) { @@ -5564,44 +5869,41 @@ function performConcurrentWorkOnRoot(root, didTimeout) { function performSyncWorkOnRoot(root) { var lastExpiredTime = root.lastExpiredTime; lastExpiredTime = 0 !== lastExpiredTime ? lastExpiredTime : 1073741823; - if (root.finishedExpirationTime === lastExpiredTime) commitRoot(root); - else { - if ((executionContext & (RenderContext | CommitContext)) !== NoContext) - throw Error("Should not already be working."); - flushPassiveEffects(); - (root === workInProgressRoot && lastExpiredTime === renderExpirationTime) || - prepareFreshStack(root, lastExpiredTime); - if (null !== workInProgress) { - var prevExecutionContext = executionContext; - executionContext |= RenderContext; - var prevDispatcher = pushDispatcher(root); - do - try { - workLoopSync(); - break; - } catch (thrownValue) { - handleError(root, thrownValue); - } - while (1); - resetContextDependencies(); - executionContext = prevExecutionContext; - ReactCurrentDispatcher.current = prevDispatcher; - if (workInProgressRootExitStatus === RootFatalErrored) - throw ((prevExecutionContext = workInProgressRootFatalError), - prepareFreshStack(root, lastExpiredTime), - markRootSuspendedAtTime(root, lastExpiredTime), - ensureRootIsScheduled(root), - prevExecutionContext); - if (null !== workInProgress) - throw Error( - "Cannot commit an incomplete root. This error is likely caused by a bug in React. Please file an issue." - ); - root.finishedWork = root.current.alternate; - root.finishedExpirationTime = lastExpiredTime; - workInProgressRoot = null; - commitRoot(root); - ensureRootIsScheduled(root); - } + if ((executionContext & (RenderContext | CommitContext)) !== NoContext) + throw Error("Should not already be working."); + flushPassiveEffects(); + (root === workInProgressRoot && lastExpiredTime === renderExpirationTime) || + prepareFreshStack(root, lastExpiredTime); + if (null !== workInProgress) { + var prevExecutionContext = executionContext; + executionContext |= RenderContext; + var prevDispatcher = pushDispatcher(root); + do + try { + workLoopSync(); + break; + } catch (thrownValue) { + handleError(root, thrownValue); + } + while (1); + resetContextDependencies(); + executionContext = prevExecutionContext; + ReactCurrentDispatcher.current = prevDispatcher; + if (workInProgressRootExitStatus === RootFatalErrored) + throw ((prevExecutionContext = workInProgressRootFatalError), + prepareFreshStack(root, lastExpiredTime), + markRootSuspendedAtTime(root, lastExpiredTime), + ensureRootIsScheduled(root), + prevExecutionContext); + if (null !== workInProgress) + throw Error( + "Cannot commit an incomplete root. This error is likely caused by a bug in React. Please file an issue." + ); + root.finishedWork = root.current.alternate; + root.finishedExpirationTime = lastExpiredTime; + workInProgressRoot = null; + commitRoot(root); + ensureRootIsScheduled(root); } return null; } @@ -5687,8 +5989,15 @@ function handleError(root$jscomp$0, thrownValue) { "object" === typeof value && "function" === typeof value.then ) { - var thenable = value, - hasInvisibleParentBoundary = + var thenable = value; + if (0 === (sourceFiber.mode & 2)) { + var currentSource = sourceFiber.alternate; + currentSource + ? ((sourceFiber.memoizedState = currentSource.memoizedState), + (sourceFiber.expirationTime = currentSource.expirationTime)) + : (sourceFiber.memoizedState = null); + } + var hasInvisibleParentBoundary = 0 !== (suspenseStackCursor.current & 1), _workInProgress = returnFiber; do { @@ -5856,346 +6165,30 @@ function completeUnitOfWork(unitOfWork) { var current$$1 = workInProgress.alternate; unitOfWork = workInProgress.return; if (0 === (workInProgress.effectTag & 2048)) { - a: { - var instance = current$$1; - current$$1 = workInProgress; - var renderExpirationTime$jscomp$0 = renderExpirationTime, - newProps = current$$1.pendingProps; - switch (current$$1.tag) { - case 2: - break; - case 16: - break; - case 15: - case 0: - break; - case 1: - isContextProvider(current$$1.type) && popContext(current$$1); - break; - case 3: - popHostContainer(current$$1); - popTopLevelContextObject(current$$1); - instance = current$$1.stateNode; - instance.pendingContext && - ((instance.context = instance.pendingContext), - (instance.pendingContext = null)); - updateHostContainer(current$$1); - break; - case 5: - popHostContext(current$$1); - var rootContainerInstance = requiredContext( - rootInstanceStackCursor.current - ), - type = current$$1.type; - if (null !== instance && null != current$$1.stateNode) - updateHostComponent$1( - instance, - current$$1, - type, - newProps, - rootContainerInstance - ), - instance.ref !== current$$1.ref && - (current$$1.effectTag |= 128); - else if (newProps) { - requiredContext(contextStackCursor$1.current); - instance = current$$1; - renderExpirationTime$jscomp$0 = nextReactTag; - nextReactTag += 2; - type = getViewConfigForType(type); - var updatePayload = diffProperties( - null, - emptyObject, - newProps, - type.validAttributes - ); - rootContainerInstance = createNode( - renderExpirationTime$jscomp$0, - type.uiViewClassName, - rootContainerInstance, - updatePayload, - instance - ); - instance = new ReactFabricHostComponent( - renderExpirationTime$jscomp$0, - type, - newProps, - instance - ); - instance = { - node: rootContainerInstance, - canonical: instance - }; - appendAllChildren(instance, current$$1, !1, !1); - current$$1.stateNode = instance; - null !== current$$1.ref && (current$$1.effectTag |= 128); - } else if (null === current$$1.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." - ); - break; - case 6: - if (instance && null != current$$1.stateNode) - updateHostText$1( - instance, - current$$1, - instance.memoizedProps, - newProps - ); - else { - if ("string" !== typeof newProps && null === current$$1.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." - ); - instance = requiredContext(rootInstanceStackCursor.current); - rootContainerInstance = requiredContext( - contextStackCursor$1.current - ); - current$$1.stateNode = createTextInstance( - newProps, - instance, - rootContainerInstance, - current$$1 - ); - } - break; - case 11: - break; - case 13: - pop(suspenseStackCursor, current$$1); - newProps = current$$1.memoizedState; - if (0 !== (current$$1.effectTag & 64)) { - current$$1.expirationTime = renderExpirationTime$jscomp$0; - break a; - } - newProps = null !== newProps; - rootContainerInstance = !1; - null !== instance && - ((renderExpirationTime$jscomp$0 = instance.memoizedState), - (rootContainerInstance = null !== renderExpirationTime$jscomp$0), - newProps || - null === renderExpirationTime$jscomp$0 || - ((renderExpirationTime$jscomp$0 = instance.child.sibling), - null !== renderExpirationTime$jscomp$0 && - ((type = current$$1.firstEffect), - null !== type - ? ((current$$1.firstEffect = renderExpirationTime$jscomp$0), - (renderExpirationTime$jscomp$0.nextEffect = type)) - : ((current$$1.firstEffect = current$$1.lastEffect = renderExpirationTime$jscomp$0), - (renderExpirationTime$jscomp$0.nextEffect = null)), - (renderExpirationTime$jscomp$0.effectTag = 8)))); - if ( - newProps && - !rootContainerInstance && - 0 !== (current$$1.mode & 2) - ) - if ( - (null === instance && - !0 !== current$$1.memoizedProps.unstable_avoidThisFallback) || - 0 !== (suspenseStackCursor.current & 1) - ) - workInProgressRootExitStatus === RootIncomplete && - (workInProgressRootExitStatus = RootSuspended); - else { - if ( - workInProgressRootExitStatus === RootIncomplete || - workInProgressRootExitStatus === RootSuspended - ) - workInProgressRootExitStatus = RootSuspendedWithDelay; - 0 !== workInProgressRootNextUnprocessedUpdateTime && - null !== workInProgressRoot && - (markRootSuspendedAtTime( - workInProgressRoot, - renderExpirationTime - ), - markRootUpdatedAtTime( - workInProgressRoot, - workInProgressRootNextUnprocessedUpdateTime - )); - } - newProps && (current$$1.effectTag |= 4); - break; - case 7: - break; - case 8: - break; - case 12: - break; - case 4: - popHostContainer(current$$1); - updateHostContainer(current$$1); - break; - case 10: - popProvider(current$$1); - break; - case 9: - break; - case 14: - break; - case 17: - isContextProvider(current$$1.type) && popContext(current$$1); - break; - case 19: - pop(suspenseStackCursor, current$$1); - newProps = current$$1.memoizedState; - if (null === newProps) break; - rootContainerInstance = 0 !== (current$$1.effectTag & 64); - type = newProps.rendering; - if (null === type) - if (rootContainerInstance) cutOffTailIfNeeded(newProps, !1); - else { - if ( - workInProgressRootExitStatus !== RootIncomplete || - (null !== instance && 0 !== (instance.effectTag & 64)) - ) - for (instance = current$$1.child; null !== instance; ) { - type = findFirstSuspended(instance); - if (null !== type) { - current$$1.effectTag |= 64; - cutOffTailIfNeeded(newProps, !1); - instance = type.updateQueue; - null !== instance && - ((current$$1.updateQueue = instance), - (current$$1.effectTag |= 4)); - null === newProps.lastEffect && - (current$$1.firstEffect = null); - current$$1.lastEffect = newProps.lastEffect; - instance = renderExpirationTime$jscomp$0; - for (newProps = current$$1.child; null !== newProps; ) - (rootContainerInstance = newProps), - (renderExpirationTime$jscomp$0 = instance), - (rootContainerInstance.effectTag &= 2), - (rootContainerInstance.nextEffect = null), - (rootContainerInstance.firstEffect = null), - (rootContainerInstance.lastEffect = null), - (type = rootContainerInstance.alternate), - null === type - ? ((rootContainerInstance.childExpirationTime = 0), - (rootContainerInstance.expirationTime = renderExpirationTime$jscomp$0), - (rootContainerInstance.child = null), - (rootContainerInstance.memoizedProps = null), - (rootContainerInstance.memoizedState = null), - (rootContainerInstance.updateQueue = null), - (rootContainerInstance.dependencies = null)) - : ((rootContainerInstance.childExpirationTime = - type.childExpirationTime), - (rootContainerInstance.expirationTime = - type.expirationTime), - (rootContainerInstance.child = type.child), - (rootContainerInstance.memoizedProps = - type.memoizedProps), - (rootContainerInstance.memoizedState = - type.memoizedState), - (rootContainerInstance.updateQueue = - type.updateQueue), - (renderExpirationTime$jscomp$0 = - type.dependencies), - (rootContainerInstance.dependencies = - null === renderExpirationTime$jscomp$0 - ? null - : { - expirationTime: - renderExpirationTime$jscomp$0.expirationTime, - firstContext: - renderExpirationTime$jscomp$0.firstContext, - responders: - renderExpirationTime$jscomp$0.responders - })), - (newProps = newProps.sibling); - push( - suspenseStackCursor, - (suspenseStackCursor.current & 1) | 2, - current$$1 - ); - current$$1 = current$$1.child; - break a; - } - instance = instance.sibling; - } - } - else { - if (!rootContainerInstance) - if ( - ((instance = findFirstSuspended(type)), null !== instance) - ) { - if ( - ((current$$1.effectTag |= 64), - (rootContainerInstance = !0), - (instance = instance.updateQueue), - null !== instance && - ((current$$1.updateQueue = instance), - (current$$1.effectTag |= 4)), - cutOffTailIfNeeded(newProps, !0), - null === newProps.tail && - "hidden" === newProps.tailMode && - !type.alternate) - ) { - current$$1 = current$$1.lastEffect = newProps.lastEffect; - null !== current$$1 && (current$$1.nextEffect = null); - break; - } - } else - now() > newProps.tailExpiration && - 1 < renderExpirationTime$jscomp$0 && - ((current$$1.effectTag |= 64), - (rootContainerInstance = !0), - cutOffTailIfNeeded(newProps, !1), - (current$$1.expirationTime = current$$1.childExpirationTime = - renderExpirationTime$jscomp$0 - 1)); - newProps.isBackwards - ? ((type.sibling = current$$1.child), (current$$1.child = type)) - : ((instance = newProps.last), - null !== instance - ? (instance.sibling = type) - : (current$$1.child = type), - (newProps.last = type)); - } - if (null !== newProps.tail) { - 0 === newProps.tailExpiration && - (newProps.tailExpiration = now() + 500); - instance = newProps.tail; - newProps.rendering = instance; - newProps.tail = instance.sibling; - newProps.lastEffect = current$$1.lastEffect; - instance.sibling = null; - newProps = suspenseStackCursor.current; - newProps = rootContainerInstance - ? (newProps & 1) | 2 - : newProps & 1; - push(suspenseStackCursor, newProps, current$$1); - current$$1 = instance; - break a; - } - break; - case 20: - break; - case 21: - break; - default: - throw Error( - "Unknown unit of work tag (" + - current$$1.tag + - "). This error is likely caused by a bug in React. Please file an issue." - ); - } - current$$1 = null; - } - instance = workInProgress; - if (1 === renderExpirationTime || 1 !== instance.childExpirationTime) { - newProps = 0; + current$$1 = completeWork( + current$$1, + workInProgress, + renderExpirationTime + ); + var completedWork = workInProgress; + if ( + 1 === renderExpirationTime || + 1 !== completedWork.childExpirationTime + ) { for ( - rootContainerInstance = instance.child; - null !== rootContainerInstance; + var newChildExpirationTime = 0, _child = completedWork.child; + null !== _child; - ) - (renderExpirationTime$jscomp$0 = - rootContainerInstance.expirationTime), - (type = rootContainerInstance.childExpirationTime), - renderExpirationTime$jscomp$0 > newProps && - (newProps = renderExpirationTime$jscomp$0), - type > newProps && (newProps = type), - (rootContainerInstance = rootContainerInstance.sibling); - instance.childExpirationTime = newProps; + ) { + var _childUpdateExpirationTime = _child.expirationTime, + _childChildExpirationTime = _child.childExpirationTime; + _childUpdateExpirationTime > newChildExpirationTime && + (newChildExpirationTime = _childUpdateExpirationTime); + _childChildExpirationTime > newChildExpirationTime && + (newChildExpirationTime = _childChildExpirationTime); + _child = _child.sibling; + } + completedWork.childExpirationTime = newChildExpirationTime; } if (null !== current$$1) return current$$1; null !== unitOfWork && @@ -6234,11 +6227,12 @@ function getRemainingExpirationTime(fiber) { } function commitRoot(root) { var renderPriorityLevel = getCurrentPriorityLevel(); - runWithPriority$1(99, commitRootImpl.bind(null, root, renderPriorityLevel)); + runWithPriority(99, commitRootImpl.bind(null, root, renderPriorityLevel)); return null; } function commitRootImpl(root$jscomp$1, renderPriorityLevel$jscomp$1) { - flushPassiveEffects(); + do flushPassiveEffects(); + while (null !== rootWithPendingPassiveEffects); if ((executionContext & (RenderContext | CommitContext)) !== NoContext) throw Error("Should not already be working."); var finishedWork = root$jscomp$1.finishedWork, @@ -6369,101 +6363,34 @@ function commitRootImpl(root$jscomp$1, renderPriorityLevel$jscomp$1) { nextEffect = remainingExpirationTimeBeforeCommit; do try { - for (effectTag = expirationTime; null !== nextEffect; ) { + for ( + effectTag = root$jscomp$1, current$$1 = expirationTime; + null !== nextEffect; + + ) { var effectTag$jscomp$0 = nextEffect.effectTag; - if (effectTag$jscomp$0 & 36) { - var current$$1$jscomp$1 = nextEffect.alternate; - current$$1 = nextEffect; - currentRef = effectTag; - switch (current$$1.tag) { - case 0: - case 11: - case 15: - commitHookEffectList(16, 32, current$$1); - break; - case 1: - var instance = current$$1.stateNode; - if (current$$1.effectTag & 4) - if (null === current$$1$jscomp$1) - instance.componentDidMount(); - else { - var prevProps = - current$$1.elementType === current$$1.type - ? current$$1$jscomp$1.memoizedProps - : resolveDefaultProps( - current$$1.type, - current$$1$jscomp$1.memoizedProps - ); - instance.componentDidUpdate( - prevProps, - current$$1$jscomp$1.memoizedState, - instance.__reactInternalSnapshotBeforeUpdate - ); - } - var updateQueue = current$$1.updateQueue; - null !== updateQueue && - commitUpdateQueue( - current$$1, - updateQueue, - instance, - currentRef - ); - break; - case 3: - var _updateQueue = current$$1.updateQueue; - if (null !== _updateQueue) { - root = null; - if (null !== current$$1.child) - switch (current$$1.child.tag) { - case 5: - root = current$$1.child.stateNode.canonical; - break; - case 1: - root = current$$1.child.stateNode; - } - commitUpdateQueue(current$$1, _updateQueue, root, currentRef); - } - break; - case 5: - if (null === current$$1$jscomp$1 && current$$1.effectTag & 4) - throw Error( - "The current renderer does not support mutation. This error is likely caused by a bug in React. Please file an issue." - ); - break; - case 6: - break; - case 4: - break; - case 12: - break; - case 13: - break; - case 19: - case 17: - case 20: - case 21: - 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." - ); - } - } + effectTag$jscomp$0 & 36 && + commitLifeCycles( + effectTag, + nextEffect.alternate, + nextEffect, + current$$1 + ); if (effectTag$jscomp$0 & 128) { - current$$1 = void 0; + currentRef = void 0; var ref = nextEffect.ref; if (null !== ref) { - var instance$jscomp$0 = nextEffect.stateNode; + var instance = nextEffect.stateNode; switch (nextEffect.tag) { case 5: - current$$1 = instance$jscomp$0.canonical; + currentRef = instance.canonical; break; default: - current$$1 = instance$jscomp$0; + currentRef = instance; } "function" === typeof ref - ? ref(current$$1) - : (ref.current = current$$1); + ? ref(currentRef) + : (ref.current = currentRef); } } nextEffect = nextEffect.nextEffect; @@ -6533,7 +6460,7 @@ function flushPassiveEffects() { ? 97 : pendingPassiveEffectsRenderPriority; pendingPassiveEffectsRenderPriority = 90; - return runWithPriority$1(priorityLevel, flushPassiveEffectsImpl); + return runWithPriority(priorityLevel, flushPassiveEffectsImpl); } } function flushPassiveEffectsImpl() { @@ -6552,6 +6479,7 @@ function flushPassiveEffectsImpl() { case 0: case 11: case 15: + case 22: commitHookEffectList(128, 0, finishedWork), commitHookEffectList(0, 64, finishedWork); } @@ -6761,6 +6689,7 @@ beginWork$$1 = function(current$$1, workInProgress, renderExpirationTime) { null !== renderState.state && void 0 !== renderState.state ? renderState.state : null; + initializeUpdateQueue(workInProgress); var getDerivedStateFromProps = updateExpirationTime.getDerivedStateFromProps; "function" === typeof getDerivedStateFromProps && @@ -6798,62 +6727,63 @@ beginWork$$1 = function(current$$1, workInProgress, renderExpirationTime) { (workInProgress = workInProgress.child); return workInProgress; case 16: - renderState = workInProgress.elementType; - null !== current$$1 && - ((current$$1.alternate = null), - (workInProgress.alternate = null), - (workInProgress.effectTag |= 2)); - current$$1 = workInProgress.pendingProps; - initializeLazyComponentType(renderState); - if (1 !== renderState._status) throw renderState._result; - renderState = renderState._result; - workInProgress.type = renderState; - hasContext = workInProgress.tag = resolveLazyComponentTag(renderState); - current$$1 = resolveDefaultProps(renderState, current$$1); - switch (hasContext) { - case 0: - workInProgress = updateFunctionComponent( - null, - workInProgress, - renderState, - current$$1, - renderExpirationTime - ); - break; - case 1: - workInProgress = updateClassComponent( - null, - workInProgress, - renderState, - current$$1, - renderExpirationTime - ); - break; - case 11: - workInProgress = updateForwardRef( - null, - workInProgress, - renderState, - current$$1, - renderExpirationTime - ); - break; - case 14: - workInProgress = updateMemoComponent( - null, - workInProgress, - renderState, - resolveDefaultProps(renderState.type, current$$1), - updateExpirationTime, - renderExpirationTime - ); - break; - default: - throw Error( - "Element type is invalid. Received a promise that resolves to: " + - renderState + - ". Lazy element type must resolve to a class or function." - ); + a: { + renderState = workInProgress.elementType; + null !== current$$1 && + ((current$$1.alternate = null), + (workInProgress.alternate = null), + (workInProgress.effectTag |= 2)); + current$$1 = workInProgress.pendingProps; + initializeLazyComponentType(renderState); + if (1 !== renderState._status) throw renderState._result; + renderState = renderState._result; + workInProgress.type = renderState; + hasContext = workInProgress.tag = resolveLazyComponentTag(renderState); + current$$1 = resolveDefaultProps(renderState, current$$1); + switch (hasContext) { + case 0: + workInProgress = updateFunctionComponent( + null, + workInProgress, + renderState, + current$$1, + renderExpirationTime + ); + break a; + case 1: + workInProgress = updateClassComponent( + null, + workInProgress, + renderState, + current$$1, + renderExpirationTime + ); + break a; + case 11: + workInProgress = updateForwardRef( + null, + workInProgress, + renderState, + current$$1, + renderExpirationTime + ); + break a; + case 14: + workInProgress = updateMemoComponent( + null, + workInProgress, + renderState, + resolveDefaultProps(renderState.type, current$$1), + updateExpirationTime, + renderExpirationTime + ); + break a; + } + throw Error( + "Element type is invalid. Received a promise that resolves to: " + + renderState + + ". Lazy element type must resolve to a class or function." + ); } return workInProgress; case 0: @@ -6891,16 +6821,17 @@ beginWork$$1 = function(current$$1, workInProgress, renderExpirationTime) { case 3: pushHostRootContext(workInProgress); updateExpirationTime = workInProgress.updateQueue; - if (null === updateExpirationTime) + if (null === current$$1 || null === updateExpirationTime) throw Error( "If the root does not have an updateQueue, we should have already bailed out. This error is likely caused by a bug in React. Please file an issue." ); + updateExpirationTime = workInProgress.pendingProps; renderState = workInProgress.memoizedState; renderState = null !== renderState ? renderState.element : null; + cloneUpdateQueue(current$$1, workInProgress); processUpdateQueue( workInProgress, updateExpirationTime, - workInProgress.pendingProps, null, renderExpirationTime ); @@ -7384,6 +7315,9 @@ function createFiberFromTypeAndProps( fiberTag = 16; owner = null; break a; + case REACT_CHUNK_TYPE: + fiberTag = 22; + break a; } throw Error( "Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: " + @@ -7559,7 +7493,11 @@ function createPortal(children, containerInfo, implementation) { implementation: implementation }; } -var fabricDispatchCommand = nativeFabricUIManager.dispatchCommand; +function _inheritsLoose(subClass, superClass) { + subClass.prototype = Object.create(superClass.prototype); + subClass.prototype.constructor = subClass; + subClass.__proto__ = superClass; +} function findNodeHandle(componentOrHandle) { if (null == componentOrHandle) return null; if ("number" === typeof componentOrHandle) return componentOrHandle; @@ -7700,12 +7638,17 @@ var roots = new Map(), findNodeHandle: findNodeHandle, dispatchCommand: function(handle, command, args) { null != handle._nativeTag && - null != handle._internalInstanceHandle && - fabricDispatchCommand( - handle._internalInstanceHandle.stateNode.node, - command, - args - ); + (handle._internalInstanceHandle + ? nativeFabricUIManager.dispatchCommand( + handle._internalInstanceHandle.stateNode.node, + command, + args + ) + : ReactNativePrivateInterface.UIManager.dispatchViewManagerCommand( + handle._nativeTag, + command, + args + )); }, render: function(element, containerTag, callback) { var root = roots.get(containerTag); @@ -7714,6 +7657,7 @@ var roots = new Map(), var uninitializedFiber = createFiber(3, null, null, 0); root.current = uninitializedFiber; uninitializedFiber.stateNode = root; + initializeUpdateQueue(uninitializedFiber); roots.set(containerTag, root); } updateContainer(element, root, null, callback); @@ -7863,7 +7807,7 @@ var roots = new Map(), throw Error("getInspectorDataForViewTag() is not available in production"); }, bundleType: 0, - version: "16.11.0", + version: "16.12.0-experimental-19f6fe170", rendererPackageName: "react-native-renderer" }); var ReactFabric$2 = { default: ReactFabric }, diff --git a/Libraries/Renderer/implementations/ReactFabric-prod.js b/Libraries/Renderer/implementations/ReactFabric-prod.js index 21270fe18669b9..521068f8747c5d 100644 --- a/Libraries/Renderer/implementations/ReactFabric-prod.js +++ b/Libraries/Renderer/implementations/ReactFabric-prod.js @@ -503,53 +503,27 @@ function recordTouchStart(touch) { } function recordTouchMove(touch) { var touchRecord = touchBank[getTouchIdentifier(touch)]; - touchRecord - ? ((touchRecord.touchActive = !0), - (touchRecord.previousPageX = touchRecord.currentPageX), - (touchRecord.previousPageY = touchRecord.currentPageY), - (touchRecord.previousTimeStamp = touchRecord.currentTimeStamp), - (touchRecord.currentPageX = touch.pageX), - (touchRecord.currentPageY = touch.pageY), - (touchRecord.currentTimeStamp = timestampForTouch(touch)), - (touchHistory.mostRecentTimeStamp = timestampForTouch(touch))) - : console.warn( - "Cannot record touch move without a touch start.\nTouch Move: %s\n", - "Touch Bank: %s", - printTouch(touch), - printTouchBank() - ); + touchRecord && + ((touchRecord.touchActive = !0), + (touchRecord.previousPageX = touchRecord.currentPageX), + (touchRecord.previousPageY = touchRecord.currentPageY), + (touchRecord.previousTimeStamp = touchRecord.currentTimeStamp), + (touchRecord.currentPageX = touch.pageX), + (touchRecord.currentPageY = touch.pageY), + (touchRecord.currentTimeStamp = timestampForTouch(touch)), + (touchHistory.mostRecentTimeStamp = timestampForTouch(touch))); } function recordTouchEnd(touch) { var touchRecord = touchBank[getTouchIdentifier(touch)]; - touchRecord - ? ((touchRecord.touchActive = !1), - (touchRecord.previousPageX = touchRecord.currentPageX), - (touchRecord.previousPageY = touchRecord.currentPageY), - (touchRecord.previousTimeStamp = touchRecord.currentTimeStamp), - (touchRecord.currentPageX = touch.pageX), - (touchRecord.currentPageY = touch.pageY), - (touchRecord.currentTimeStamp = timestampForTouch(touch)), - (touchHistory.mostRecentTimeStamp = timestampForTouch(touch))) - : console.warn( - "Cannot record touch end without a touch start.\nTouch End: %s\n", - "Touch Bank: %s", - printTouch(touch), - printTouchBank() - ); -} -function printTouch(touch) { - return JSON.stringify({ - identifier: touch.identifier, - pageX: touch.pageX, - pageY: touch.pageY, - timestamp: timestampForTouch(touch) - }); -} -function printTouchBank() { - var printed = JSON.stringify(touchBank.slice(0, 20)); - 20 < touchBank.length && - (printed += " (original size: " + touchBank.length + ")"); - return printed; + touchRecord && + ((touchRecord.touchActive = !1), + (touchRecord.previousPageX = touchRecord.currentPageX), + (touchRecord.previousPageY = touchRecord.currentPageY), + (touchRecord.previousTimeStamp = touchRecord.currentTimeStamp), + (touchRecord.currentPageX = touch.pageX), + (touchRecord.currentPageY = touch.pageY), + (touchRecord.currentTimeStamp = timestampForTouch(touch)), + (touchHistory.mostRecentTimeStamp = timestampForTouch(touch))); } var ResponderTouchHistoryStore = { recordTouchTrack: function(topLevelType, nativeEvent) { @@ -682,13 +656,7 @@ var eventTypes = { "topTouchCancel" === topLevelType ) if (0 <= trackedTouchCount) --trackedTouchCount; - else - return ( - console.warn( - "Ended a touch event which was not counted in `trackedTouchCount`." - ), - null - ); + else return null; ResponderTouchHistoryStore.recordTouchTrack(topLevelType, nativeEvent); if ( targetInst && @@ -1035,7 +1003,8 @@ var hasSymbol = "function" === typeof Symbol && Symbol.for, ? Symbol.for("react.suspense_list") : 60120, REACT_MEMO_TYPE = hasSymbol ? Symbol.for("react.memo") : 60115, - REACT_LAZY_TYPE = hasSymbol ? Symbol.for("react.lazy") : 60116; + REACT_LAZY_TYPE = hasSymbol ? Symbol.for("react.lazy") : 60116, + REACT_CHUNK_TYPE = hasSymbol ? Symbol.for("react.chunk") : 60121; hasSymbol && Symbol.for("react.fundamental"); hasSymbol && Symbol.for("react.responder"); hasSymbol && Symbol.for("react.scope"); @@ -1100,6 +1069,8 @@ function getComponentName(type) { ); case REACT_MEMO_TYPE: return getComponentName(type.type); + case REACT_CHUNK_TYPE: + return getComponentName(type.render); case REACT_LAZY_TYPE: if ((type = 1 === type._status ? type._result : null)) return getComponentName(type); @@ -1487,26 +1458,6 @@ function batchedUpdates(fn, bookkeeping) { restoreStateOfTarget(fn[bookkeeping]); } } -function _inheritsLoose(subClass, superClass) { - subClass.prototype = Object.create(superClass.prototype); - subClass.prototype.constructor = subClass; - subClass.__proto__ = superClass; -} -(function(_React$Component) { - function ReactNativeComponent() { - return _React$Component.apply(this, arguments) || this; - } - _inheritsLoose(ReactNativeComponent, _React$Component); - var _proto = ReactNativeComponent.prototype; - _proto.blur = function() {}; - _proto.focus = function() {}; - _proto.measure = function() {}; - _proto.measureInWindow = function() {}; - _proto.measureLayout = function() {}; - _proto.setNativeProps = function() {}; - return ReactNativeComponent; -})(React.Component); -new Map(); function dispatchEvent(target, topLevelType, nativeEvent) { var eventTarget = null; eventTarget = nativeEvent.target; @@ -1547,21 +1498,21 @@ function shim$1() { "The current renderer does not support hydration. This error is likely caused by a bug in React. Please file an issue." ); } -var _nativeFabricUIManage$1 = nativeFabricUIManager, - createNode = _nativeFabricUIManage$1.createNode, - cloneNode = _nativeFabricUIManage$1.cloneNode, - cloneNodeWithNewChildren = _nativeFabricUIManage$1.cloneNodeWithNewChildren, +var _nativeFabricUIManage = nativeFabricUIManager, + createNode = _nativeFabricUIManage.createNode, + cloneNode = _nativeFabricUIManage.cloneNode, + cloneNodeWithNewChildren = _nativeFabricUIManage.cloneNodeWithNewChildren, cloneNodeWithNewChildrenAndProps = - _nativeFabricUIManage$1.cloneNodeWithNewChildrenAndProps, - cloneNodeWithNewProps = _nativeFabricUIManage$1.cloneNodeWithNewProps, - createChildNodeSet = _nativeFabricUIManage$1.createChildSet, - appendChildNode = _nativeFabricUIManage$1.appendChild, - appendChildNodeToSet = _nativeFabricUIManage$1.appendChildToSet, - completeRoot = _nativeFabricUIManage$1.completeRoot, - registerEventHandler = _nativeFabricUIManage$1.registerEventHandler, - fabricMeasure = _nativeFabricUIManage$1.measure, - fabricMeasureInWindow = _nativeFabricUIManage$1.measureInWindow, - fabricMeasureLayout = _nativeFabricUIManage$1.measureLayout, + _nativeFabricUIManage.cloneNodeWithNewChildrenAndProps, + cloneNodeWithNewProps = _nativeFabricUIManage.cloneNodeWithNewProps, + createChildNodeSet = _nativeFabricUIManage.createChildSet, + appendChildNode = _nativeFabricUIManage.appendChild, + appendChildNodeToSet = _nativeFabricUIManage.appendChildToSet, + completeRoot = _nativeFabricUIManage.completeRoot, + registerEventHandler = _nativeFabricUIManage.registerEventHandler, + fabricMeasure = _nativeFabricUIManage.measure, + fabricMeasureInWindow = _nativeFabricUIManage.measureInWindow, + fabricMeasureLayout = _nativeFabricUIManage.measureLayout, getViewConfigForType = ReactNativePrivateInterface.ReactNativeViewConfigRegistry.get, nextReactTag = 2; @@ -1838,7 +1789,7 @@ function reactPriorityToSchedulerPriority(reactPriorityLevel) { throw Error("Unknown priority level."); } } -function runWithPriority$1(reactPriorityLevel, fn) { +function runWithPriority(reactPriorityLevel, fn) { reactPriorityLevel = reactPriorityToSchedulerPriority(reactPriorityLevel); return Scheduler_runWithPriority(reactPriorityLevel, fn); } @@ -1870,7 +1821,7 @@ function flushSyncCallbackQueueImpl() { var i = 0; try { var queue = syncQueue; - runWithPriority$1(99, function() { + runWithPriority(99, function() { for (; i < queue.length; i++) { var callback = queue[i]; do callback = callback(!0); @@ -1994,237 +1945,195 @@ function readContext(context, observedBits) { return context._currentValue2; } var hasForceUpdate = !1; -function createUpdateQueue(baseState) { - return { - baseState: baseState, - firstUpdate: null, - lastUpdate: null, - firstCapturedUpdate: null, - lastCapturedUpdate: null, - firstEffect: null, - lastEffect: null, - firstCapturedEffect: null, - lastCapturedEffect: null +function initializeUpdateQueue(fiber) { + fiber.updateQueue = { + baseState: fiber.memoizedState, + baseQueue: null, + shared: { pending: null }, + effects: null }; } -function cloneUpdateQueue(currentQueue) { - return { - baseState: currentQueue.baseState, - firstUpdate: currentQueue.firstUpdate, - lastUpdate: currentQueue.lastUpdate, - firstCapturedUpdate: null, - lastCapturedUpdate: null, - firstEffect: null, - lastEffect: null, - firstCapturedEffect: null, - lastCapturedEffect: null - }; +function cloneUpdateQueue(current, workInProgress) { + current = current.updateQueue; + workInProgress.updateQueue === current && + (workInProgress.updateQueue = { + baseState: current.baseState, + baseQueue: current.baseQueue, + shared: current.shared, + effects: current.effects + }); } function createUpdate(expirationTime, suspenseConfig) { - return { + expirationTime = { expirationTime: expirationTime, suspenseConfig: suspenseConfig, tag: 0, payload: null, callback: null, - next: null, - nextEffect: null + next: null }; -} -function appendUpdateToQueue(queue, update) { - null === queue.lastUpdate - ? (queue.firstUpdate = queue.lastUpdate = update) - : ((queue.lastUpdate.next = update), (queue.lastUpdate = update)); + return (expirationTime.next = expirationTime); } function enqueueUpdate(fiber, update) { - var alternate = fiber.alternate; - if (null === alternate) { - var queue1 = fiber.updateQueue; - var queue2 = null; - null === queue1 && - (queue1 = fiber.updateQueue = createUpdateQueue(fiber.memoizedState)); - } else - (queue1 = fiber.updateQueue), - (queue2 = alternate.updateQueue), - null === queue1 - ? null === queue2 - ? ((queue1 = fiber.updateQueue = createUpdateQueue( - fiber.memoizedState - )), - (queue2 = alternate.updateQueue = createUpdateQueue( - alternate.memoizedState - ))) - : (queue1 = fiber.updateQueue = cloneUpdateQueue(queue2)) - : null === queue2 && - (queue2 = alternate.updateQueue = cloneUpdateQueue(queue1)); - null === queue2 || queue1 === queue2 - ? appendUpdateToQueue(queue1, update) - : null === queue1.lastUpdate || null === queue2.lastUpdate - ? (appendUpdateToQueue(queue1, update), - appendUpdateToQueue(queue2, update)) - : (appendUpdateToQueue(queue1, update), (queue2.lastUpdate = update)); + fiber = fiber.updateQueue; + if (null !== fiber) { + fiber = fiber.shared; + var pending = fiber.pending; + null === pending + ? (update.next = update) + : ((update.next = pending.next), (pending.next = update)); + fiber.pending = update; + } } function enqueueCapturedUpdate(workInProgress, update) { - var workInProgressQueue = workInProgress.updateQueue; - workInProgressQueue = - null === workInProgressQueue - ? (workInProgress.updateQueue = createUpdateQueue( - workInProgress.memoizedState - )) - : ensureWorkInProgressQueueIsAClone(workInProgress, workInProgressQueue); - null === workInProgressQueue.lastCapturedUpdate - ? (workInProgressQueue.firstCapturedUpdate = workInProgressQueue.lastCapturedUpdate = update) - : ((workInProgressQueue.lastCapturedUpdate.next = update), - (workInProgressQueue.lastCapturedUpdate = update)); -} -function ensureWorkInProgressQueueIsAClone(workInProgress, queue) { var current = workInProgress.alternate; - null !== current && - queue === current.updateQueue && - (queue = workInProgress.updateQueue = cloneUpdateQueue(queue)); - return queue; -} -function getStateFromUpdate( - workInProgress, - queue, - update, - prevState, - nextProps, - instance -) { - switch (update.tag) { - case 1: - return ( - (workInProgress = update.payload), - "function" === typeof workInProgress - ? workInProgress.call(instance, prevState, nextProps) - : workInProgress - ); - case 3: - workInProgress.effectTag = (workInProgress.effectTag & -4097) | 64; - case 0: - workInProgress = update.payload; - nextProps = - "function" === typeof workInProgress - ? workInProgress.call(instance, prevState, nextProps) - : workInProgress; - if (null === nextProps || void 0 === nextProps) break; - return Object.assign({}, prevState, nextProps); - case 2: - hasForceUpdate = !0; - } - return prevState; + null !== current && cloneUpdateQueue(current, workInProgress); + workInProgress = workInProgress.updateQueue; + current = workInProgress.baseQueue; + null === current + ? ((workInProgress.baseQueue = update.next = update), + (update.next = update)) + : ((update.next = current.next), (current.next = update)); } function processUpdateQueue( - workInProgress, - queue, + workInProgress$jscomp$0, props, instance, renderExpirationTime ) { + var queue = workInProgress$jscomp$0.updateQueue; hasForceUpdate = !1; - queue = ensureWorkInProgressQueueIsAClone(workInProgress, queue); - for ( - var newBaseState = queue.baseState, - newFirstUpdate = null, - newExpirationTime = 0, - update = queue.firstUpdate, - resultState = newBaseState; - null !== update; - - ) { - var updateExpirationTime = update.expirationTime; - updateExpirationTime < renderExpirationTime - ? (null === newFirstUpdate && - ((newFirstUpdate = update), (newBaseState = resultState)), - newExpirationTime < updateExpirationTime && - (newExpirationTime = updateExpirationTime)) - : (markRenderEventTimeAndConfig( - updateExpirationTime, - update.suspenseConfig - ), - (resultState = getStateFromUpdate( - workInProgress, - queue, - update, - resultState, - props, - instance - )), - null !== update.callback && - ((workInProgress.effectTag |= 32), - (update.nextEffect = null), - null === queue.lastEffect - ? (queue.firstEffect = queue.lastEffect = update) - : ((queue.lastEffect.nextEffect = update), - (queue.lastEffect = update)))); - update = update.next; + var baseQueue = queue.baseQueue, + pendingQueue = queue.shared.pending; + if (null !== pendingQueue) { + if (null !== baseQueue) { + var baseFirst = baseQueue.next; + baseQueue.next = pendingQueue.next; + pendingQueue.next = baseFirst; + } + baseQueue = pendingQueue; + queue.shared.pending = null; + baseFirst = workInProgress$jscomp$0.alternate; + null !== baseFirst && + ((baseFirst = baseFirst.updateQueue), + null !== baseFirst && (baseFirst.baseQueue = pendingQueue)); } - updateExpirationTime = null; - for (update = queue.firstCapturedUpdate; null !== update; ) { - var _updateExpirationTime = update.expirationTime; - _updateExpirationTime < renderExpirationTime - ? (null === updateExpirationTime && - ((updateExpirationTime = update), - null === newFirstUpdate && (newBaseState = resultState)), - newExpirationTime < _updateExpirationTime && - (newExpirationTime = _updateExpirationTime)) - : ((resultState = getStateFromUpdate( - workInProgress, - queue, - update, - resultState, - props, - instance - )), - null !== update.callback && - ((workInProgress.effectTag |= 32), - (update.nextEffect = null), - null === queue.lastCapturedEffect - ? (queue.firstCapturedEffect = queue.lastCapturedEffect = update) - : ((queue.lastCapturedEffect.nextEffect = update), - (queue.lastCapturedEffect = update)))); - update = update.next; + if (null !== baseQueue) { + baseFirst = baseQueue.next; + var newState = queue.baseState, + newExpirationTime = 0, + newBaseState = null, + newBaseQueueFirst = null, + newBaseQueueLast = null; + if (null !== baseFirst) { + var update = baseFirst; + do { + pendingQueue = update.expirationTime; + if (pendingQueue < renderExpirationTime) { + var clone = { + expirationTime: update.expirationTime, + suspenseConfig: update.suspenseConfig, + tag: update.tag, + payload: update.payload, + callback: update.callback, + next: null + }; + null === newBaseQueueLast + ? ((newBaseQueueFirst = newBaseQueueLast = clone), + (newBaseState = newState)) + : (newBaseQueueLast = newBaseQueueLast.next = clone); + pendingQueue > newExpirationTime && + (newExpirationTime = pendingQueue); + } else { + null !== newBaseQueueLast && + (newBaseQueueLast = newBaseQueueLast.next = { + expirationTime: 1073741823, + suspenseConfig: update.suspenseConfig, + tag: update.tag, + payload: update.payload, + callback: update.callback, + next: null + }); + markRenderEventTimeAndConfig(pendingQueue, update.suspenseConfig); + a: { + var workInProgress = workInProgress$jscomp$0, + update$jscomp$0 = update; + pendingQueue = props; + clone = instance; + switch (update$jscomp$0.tag) { + case 1: + workInProgress = update$jscomp$0.payload; + if ("function" === typeof workInProgress) { + newState = workInProgress.call(clone, newState, pendingQueue); + break a; + } + newState = workInProgress; + break a; + case 3: + workInProgress.effectTag = + (workInProgress.effectTag & -4097) | 64; + case 0: + workInProgress = update$jscomp$0.payload; + pendingQueue = + "function" === typeof workInProgress + ? workInProgress.call(clone, newState, pendingQueue) + : workInProgress; + if (null === pendingQueue || void 0 === pendingQueue) break a; + newState = Object.assign({}, newState, pendingQueue); + break a; + case 2: + hasForceUpdate = !0; + } + } + null !== update.callback && + ((workInProgress$jscomp$0.effectTag |= 32), + (pendingQueue = queue.effects), + null === pendingQueue + ? (queue.effects = [update]) + : pendingQueue.push(update)); + } + update = update.next; + if (null === update || update === baseFirst) + if (((pendingQueue = queue.shared.pending), null === pendingQueue)) + break; + else + (update = baseQueue.next = pendingQueue.next), + (pendingQueue.next = baseFirst), + (queue.baseQueue = baseQueue = pendingQueue), + (queue.shared.pending = null); + } while (1); + } + null === newBaseQueueLast + ? (newBaseState = newState) + : (newBaseQueueLast.next = newBaseQueueFirst); + queue.baseState = newBaseState; + queue.baseQueue = newBaseQueueLast; + markUnprocessedUpdateTime(newExpirationTime); + workInProgress$jscomp$0.expirationTime = newExpirationTime; + workInProgress$jscomp$0.memoizedState = newState; } - null === newFirstUpdate && (queue.lastUpdate = null); - null === updateExpirationTime - ? (queue.lastCapturedUpdate = null) - : (workInProgress.effectTag |= 32); - null === newFirstUpdate && - null === updateExpirationTime && - (newBaseState = resultState); - queue.baseState = newBaseState; - queue.firstUpdate = newFirstUpdate; - queue.firstCapturedUpdate = updateExpirationTime; - markUnprocessedUpdateTime(newExpirationTime); - workInProgress.expirationTime = newExpirationTime; - workInProgress.memoizedState = resultState; } function commitUpdateQueue(finishedWork, finishedQueue, instance) { - null !== finishedQueue.firstCapturedUpdate && - (null !== finishedQueue.lastUpdate && - ((finishedQueue.lastUpdate.next = finishedQueue.firstCapturedUpdate), - (finishedQueue.lastUpdate = finishedQueue.lastCapturedUpdate)), - (finishedQueue.firstCapturedUpdate = finishedQueue.lastCapturedUpdate = null)); - commitUpdateEffects(finishedQueue.firstEffect, instance); - finishedQueue.firstEffect = finishedQueue.lastEffect = null; - commitUpdateEffects(finishedQueue.firstCapturedEffect, instance); - finishedQueue.firstCapturedEffect = finishedQueue.lastCapturedEffect = null; -} -function commitUpdateEffects(effect, instance) { - for (; null !== effect; ) { - var callback = effect.callback; - if (null !== callback) { - effect.callback = null; - if ("function" !== typeof callback) - throw Error( - "Invalid argument passed as callback. Expected a function. Instead received: " + - callback - ); - callback.call(instance); + finishedWork = finishedQueue.effects; + finishedQueue.effects = null; + if (null !== finishedWork) + for ( + finishedQueue = 0; + finishedQueue < finishedWork.length; + finishedQueue++ + ) { + var effect = finishedWork[finishedQueue], + callback = effect.callback; + if (null !== callback) { + effect.callback = null; + if ("function" !== typeof callback) + throw Error( + "Invalid argument passed as callback. Expected a function. Instead received: " + + callback + ); + callback.call(instance); + } } - effect = effect.nextEffect; - } } var ReactCurrentBatchConfig = ReactSharedInternals.ReactCurrentBatchConfig, emptyRefsObject = new React.Component().refs; @@ -2241,10 +2150,8 @@ function applyDerivedStateFromProps( ? ctor : Object.assign({}, ctor, getDerivedStateFromProps); workInProgress.memoizedState = getDerivedStateFromProps; - nextProps = workInProgress.updateQueue; - null !== nextProps && - 0 === workInProgress.expirationTime && - (nextProps.baseState = getDerivedStateFromProps); + 0 === workInProgress.expirationTime && + (workInProgress.updateQueue.baseState = getDerivedStateFromProps); } var classComponentUpdater = { isMounted: function(component) { @@ -2359,6 +2266,7 @@ function mountClassInstance( instance.props = newProps; instance.state = workInProgress.memoizedState; instance.refs = emptyRefsObject; + initializeUpdateQueue(workInProgress); var contextType = ctor.contextType; "object" === typeof contextType && null !== contextType ? (instance.context = readContext(contextType)) @@ -2366,16 +2274,8 @@ function mountClassInstance( ? previousContext : contextStackCursor.current), (instance.context = getMaskedContext(workInProgress, contextType))); - contextType = workInProgress.updateQueue; - null !== contextType && - (processUpdateQueue( - workInProgress, - contextType, - newProps, - instance, - renderExpirationTime - ), - (instance.state = workInProgress.memoizedState)); + processUpdateQueue(workInProgress, newProps, instance, renderExpirationTime); + instance.state = workInProgress.memoizedState; contextType = ctor.getDerivedStateFromProps; "function" === typeof contextType && (applyDerivedStateFromProps(workInProgress, ctor, contextType, newProps), @@ -2391,16 +2291,13 @@ function mountClassInstance( instance.UNSAFE_componentWillMount(), ctor !== instance.state && classComponentUpdater.enqueueReplaceState(instance, instance.state, null), - (contextType = workInProgress.updateQueue), - null !== contextType && - (processUpdateQueue( - workInProgress, - contextType, - newProps, - instance, - renderExpirationTime - ), - (instance.state = workInProgress.memoizedState))); + processUpdateQueue( + workInProgress, + newProps, + instance, + renderExpirationTime + ), + (instance.state = workInProgress.memoizedState)); "function" === typeof instance.componentDidMount && (workInProgress.effectTag |= 4); } @@ -2962,39 +2859,50 @@ function ChildReconciler(shouldTrackSideEffects) { null !== isUnkeyedTopLevelFragment; ) { - if (isUnkeyedTopLevelFragment.key === isObject) - if ( - 7 === isUnkeyedTopLevelFragment.tag - ? newChild.type === REACT_FRAGMENT_TYPE - : isUnkeyedTopLevelFragment.elementType === newChild.type - ) { - deleteRemainingChildren( - returnFiber, - isUnkeyedTopLevelFragment.sibling - ); - currentFirstChild = useFiber( - isUnkeyedTopLevelFragment, - newChild.type === REACT_FRAGMENT_TYPE - ? newChild.props.children - : newChild.props, - expirationTime - ); - currentFirstChild.ref = coerceRef( - returnFiber, - isUnkeyedTopLevelFragment, - newChild - ); - currentFirstChild.return = returnFiber; - returnFiber = currentFirstChild; - break a; - } else { - deleteRemainingChildren( - returnFiber, - isUnkeyedTopLevelFragment - ); - break; + if (isUnkeyedTopLevelFragment.key === isObject) { + switch (isUnkeyedTopLevelFragment.tag) { + case 7: + if (newChild.type === REACT_FRAGMENT_TYPE) { + deleteRemainingChildren( + returnFiber, + isUnkeyedTopLevelFragment.sibling + ); + currentFirstChild = useFiber( + isUnkeyedTopLevelFragment, + newChild.props.children, + expirationTime + ); + currentFirstChild.return = returnFiber; + returnFiber = currentFirstChild; + break a; + } + break; + default: + if ( + isUnkeyedTopLevelFragment.elementType === newChild.type + ) { + deleteRemainingChildren( + returnFiber, + isUnkeyedTopLevelFragment.sibling + ); + currentFirstChild = useFiber( + isUnkeyedTopLevelFragment, + newChild.props, + expirationTime + ); + currentFirstChild.ref = coerceRef( + returnFiber, + isUnkeyedTopLevelFragment, + newChild + ); + currentFirstChild.return = returnFiber; + returnFiber = currentFirstChild; + break a; + } } - else deleteChild(returnFiber, isUnkeyedTopLevelFragment); + deleteRemainingChildren(returnFiber, isUnkeyedTopLevelFragment); + break; + } else deleteChild(returnFiber, isUnkeyedTopLevelFragment); isUnkeyedTopLevelFragment = isUnkeyedTopLevelFragment.sibling; } newChild.type === REACT_FRAGMENT_TYPE @@ -3192,7 +3100,7 @@ function findFirstSuspended(row) { } return null; } -function createResponderListener(responder, props) { +function createDeprecatedResponderListener(responder, props) { return { responder: responder, props: props }; } var ReactCurrentDispatcher$1 = ReactSharedInternals.ReactCurrentDispatcher, @@ -3200,13 +3108,7 @@ var ReactCurrentDispatcher$1 = ReactSharedInternals.ReactCurrentDispatcher, renderExpirationTime$1 = 0, currentlyRenderingFiber$1 = null, currentHook = null, - nextCurrentHook = null, - firstWorkInProgressHook = null, workInProgressHook = null, - nextWorkInProgressHook = null, - remainingExpirationTime = 0, - componentUpdateQueue = null, - sideEffectTag = 0, didScheduleRenderPhaseUpdate = !1, renderPhaseUpdates = null, numberOfReRenders = 0; @@ -3226,53 +3128,45 @@ function renderWithHooks( workInProgress, Component, props, - refOrContext, + secondArg, nextRenderExpirationTime ) { renderExpirationTime$1 = nextRenderExpirationTime; currentlyRenderingFiber$1 = workInProgress; - nextCurrentHook = null !== current ? current.memoizedState : null; + workInProgress.memoizedState = null; + workInProgress.updateQueue = null; + workInProgress.expirationTime = 0; ReactCurrentDispatcher$1.current = - null === nextCurrentHook ? HooksDispatcherOnMount : HooksDispatcherOnUpdate; - workInProgress = Component(props, refOrContext); + null === current || null === current.memoizedState + ? HooksDispatcherOnMount + : HooksDispatcherOnUpdate; + current = Component(props, secondArg); if (didScheduleRenderPhaseUpdate) { do (didScheduleRenderPhaseUpdate = !1), (numberOfReRenders += 1), - (nextCurrentHook = null !== current ? current.memoizedState : null), - (nextWorkInProgressHook = firstWorkInProgressHook), - (componentUpdateQueue = workInProgressHook = currentHook = null), + (workInProgressHook = currentHook = null), + (workInProgress.updateQueue = null), (ReactCurrentDispatcher$1.current = HooksDispatcherOnUpdate), - (workInProgress = Component(props, refOrContext)); + (current = Component(props, secondArg)); while (didScheduleRenderPhaseUpdate); renderPhaseUpdates = null; numberOfReRenders = 0; } ReactCurrentDispatcher$1.current = ContextOnlyDispatcher; - current = currentlyRenderingFiber$1; - current.memoizedState = firstWorkInProgressHook; - current.expirationTime = remainingExpirationTime; - current.updateQueue = componentUpdateQueue; - current.effectTag |= sideEffectTag; - current = null !== currentHook && null !== currentHook.next; + workInProgress = null !== currentHook && null !== currentHook.next; renderExpirationTime$1 = 0; - nextWorkInProgressHook = workInProgressHook = firstWorkInProgressHook = nextCurrentHook = currentHook = currentlyRenderingFiber$1 = null; - remainingExpirationTime = 0; - componentUpdateQueue = null; - sideEffectTag = 0; - if (current) + workInProgressHook = currentHook = currentlyRenderingFiber$1 = null; + if (workInProgress) throw Error( "Rendered fewer hooks than expected. This may be caused by an accidental early return statement." ); - return workInProgress; + return current; } function resetHooks() { ReactCurrentDispatcher$1.current = ContextOnlyDispatcher; renderExpirationTime$1 = 0; - nextWorkInProgressHook = workInProgressHook = firstWorkInProgressHook = nextCurrentHook = currentHook = currentlyRenderingFiber$1 = null; - remainingExpirationTime = 0; - componentUpdateQueue = null; - sideEffectTag = 0; + workInProgressHook = currentHook = currentlyRenderingFiber$1 = null; didScheduleRenderPhaseUpdate = !1; renderPhaseUpdates = null; numberOfReRenders = 0; @@ -3281,37 +3175,42 @@ function mountWorkInProgressHook() { var hook = { memoizedState: null, baseState: null, + baseQueue: null, queue: null, - baseUpdate: null, next: null }; null === workInProgressHook - ? (firstWorkInProgressHook = workInProgressHook = hook) + ? (currentlyRenderingFiber$1.memoizedState = workInProgressHook = hook) : (workInProgressHook = workInProgressHook.next = hook); return workInProgressHook; } function updateWorkInProgressHook() { + if (null === currentHook) { + var nextCurrentHook = currentlyRenderingFiber$1.alternate; + nextCurrentHook = + null !== nextCurrentHook ? nextCurrentHook.memoizedState : null; + } else nextCurrentHook = currentHook.next; + var nextWorkInProgressHook = + null === workInProgressHook + ? currentlyRenderingFiber$1.memoizedState + : workInProgressHook.next; if (null !== nextWorkInProgressHook) (workInProgressHook = nextWorkInProgressHook), - (nextWorkInProgressHook = workInProgressHook.next), - (currentHook = nextCurrentHook), - (nextCurrentHook = null !== currentHook ? currentHook.next : null); + (currentHook = nextCurrentHook); else { if (null === nextCurrentHook) throw Error("Rendered more hooks than during the previous render."); currentHook = nextCurrentHook; - var newHook = { + nextCurrentHook = { memoizedState: currentHook.memoizedState, baseState: currentHook.baseState, + baseQueue: currentHook.baseQueue, queue: currentHook.queue, - baseUpdate: currentHook.baseUpdate, next: null }; - workInProgressHook = - null === workInProgressHook - ? (firstWorkInProgressHook = newHook) - : (workInProgressHook.next = newHook); - nextCurrentHook = currentHook.next; + null === workInProgressHook + ? (currentlyRenderingFiber$1.memoizedState = workInProgressHook = nextCurrentHook) + : (workInProgressHook = workInProgressHook.next = nextCurrentHook); } return workInProgressHook; } @@ -3339,51 +3238,75 @@ function updateReducer(reducer) { while (null !== firstRenderPhaseUpdate); is$1(newState, hook.memoizedState) || (didReceiveUpdate = !0); hook.memoizedState = newState; - hook.baseUpdate === queue.last && (hook.baseState = newState); + null === hook.baseQueue && (hook.baseState = newState); queue.lastRenderedState = newState; return [newState, _dispatch]; } } return [hook.memoizedState, _dispatch]; } - _dispatch = queue.last; - var baseUpdate = hook.baseUpdate; - newState = hook.baseState; - null !== baseUpdate - ? (null !== _dispatch && (_dispatch.next = null), - (_dispatch = baseUpdate.next)) - : (_dispatch = null !== _dispatch ? _dispatch.next : null); + newState = currentHook; + _dispatch = newState.baseQueue; + firstRenderPhaseUpdate = queue.pending; + if (null !== firstRenderPhaseUpdate) { + if (null !== _dispatch) { + var baseFirst = _dispatch.next; + _dispatch.next = firstRenderPhaseUpdate.next; + firstRenderPhaseUpdate.next = baseFirst; + } + newState.baseQueue = _dispatch = firstRenderPhaseUpdate; + queue.pending = null; + } if (null !== _dispatch) { - var newBaseUpdate = (firstRenderPhaseUpdate = null), - _update = _dispatch, - didSkip = !1; + _dispatch = _dispatch.next; + newState = newState.baseState; + var newBaseQueueLast = (baseFirst = firstRenderPhaseUpdate = null), + _update = _dispatch; do { var updateExpirationTime = _update.expirationTime; - updateExpirationTime < renderExpirationTime$1 - ? (didSkip || - ((didSkip = !0), - (newBaseUpdate = baseUpdate), - (firstRenderPhaseUpdate = newState)), - updateExpirationTime > remainingExpirationTime && - ((remainingExpirationTime = updateExpirationTime), - markUnprocessedUpdateTime(remainingExpirationTime))) - : (markRenderEventTimeAndConfig( + if (updateExpirationTime < renderExpirationTime$1) { + var clone = { + expirationTime: _update.expirationTime, + suspenseConfig: _update.suspenseConfig, + action: _update.action, + eagerReducer: _update.eagerReducer, + eagerState: _update.eagerState, + next: null + }; + null === newBaseQueueLast + ? ((baseFirst = newBaseQueueLast = clone), + (firstRenderPhaseUpdate = newState)) + : (newBaseQueueLast = newBaseQueueLast.next = clone); + updateExpirationTime > currentlyRenderingFiber$1.expirationTime && + ((currentlyRenderingFiber$1.expirationTime = updateExpirationTime), + markUnprocessedUpdateTime(updateExpirationTime)); + } else + null !== newBaseQueueLast && + (newBaseQueueLast = newBaseQueueLast.next = { + expirationTime: 1073741823, + suspenseConfig: _update.suspenseConfig, + action: _update.action, + eagerReducer: _update.eagerReducer, + eagerState: _update.eagerState, + next: null + }), + markRenderEventTimeAndConfig( updateExpirationTime, _update.suspenseConfig ), (newState = _update.eagerReducer === reducer ? _update.eagerState - : reducer(newState, _update.action))); - baseUpdate = _update; + : reducer(newState, _update.action)); _update = _update.next; } while (null !== _update && _update !== _dispatch); - didSkip || - ((newBaseUpdate = baseUpdate), (firstRenderPhaseUpdate = newState)); + null === newBaseQueueLast + ? (firstRenderPhaseUpdate = newState) + : (newBaseQueueLast.next = baseFirst); is$1(newState, hook.memoizedState) || (didReceiveUpdate = !0); hook.memoizedState = newState; - hook.baseUpdate = newBaseUpdate; hook.baseState = firstRenderPhaseUpdate; + hook.baseQueue = newBaseQueueLast; queue.lastRenderedState = newState; } return [hook.memoizedState, queue.dispatch]; @@ -3393,7 +3316,7 @@ function mountState(initialState) { "function" === typeof initialState && (initialState = initialState()); hook.memoizedState = hook.baseState = initialState; initialState = hook.queue = { - last: null, + pending: null, dispatch: null, lastRenderedReducer: basicStateReducer, lastRenderedState: initialState @@ -3410,21 +3333,23 @@ function updateState(initialState) { } function pushEffect(tag, create, destroy, deps) { tag = { tag: tag, create: create, destroy: destroy, deps: deps, next: null }; - null === componentUpdateQueue - ? ((componentUpdateQueue = { lastEffect: null }), - (componentUpdateQueue.lastEffect = tag.next = tag)) - : ((create = componentUpdateQueue.lastEffect), - null === create - ? (componentUpdateQueue.lastEffect = tag.next = tag) - : ((destroy = create.next), - (create.next = tag), - (tag.next = destroy), - (componentUpdateQueue.lastEffect = tag))); + create = currentlyRenderingFiber$1.updateQueue; + null === create + ? ((create = { lastEffect: null }), + (currentlyRenderingFiber$1.updateQueue = create), + (create.lastEffect = tag.next = tag)) + : ((destroy = create.lastEffect), + null === destroy + ? (create.lastEffect = tag.next = tag) + : ((deps = destroy.next), + (destroy.next = tag), + (tag.next = deps), + (create.lastEffect = tag))); return tag; } function mountEffectImpl(fiberEffectTag, hookEffectTag, create, deps) { var hook = mountWorkInProgressHook(); - sideEffectTag |= fiberEffectTag; + currentlyRenderingFiber$1.effectTag |= fiberEffectTag; hook.memoizedState = pushEffect( hookEffectTag, create, @@ -3444,7 +3369,7 @@ function updateEffectImpl(fiberEffectTag, hookEffectTag, create, deps) { return; } } - sideEffectTag |= fiberEffectTag; + currentlyRenderingFiber$1.effectTag |= fiberEffectTag; hook.memoizedState = pushEffect(hookEffectTag, create, destroy, deps); } function mountEffect(create, deps) { @@ -3492,6 +3417,21 @@ function updateCallback(callback, deps) { hook.memoizedState = [callback, deps]; return callback; } +function startTransition(setPending, config, callback) { + var priorityLevel = getCurrentPriorityLevel(); + runWithPriority(98 > priorityLevel ? 98 : priorityLevel, function() { + setPending(!0); + }); + runWithPriority(97 < priorityLevel ? 97 : priorityLevel, function() { + var previousConfig = ReactCurrentBatchConfig$1.suspense; + ReactCurrentBatchConfig$1.suspense = void 0 === config ? null : config; + try { + setPending(!1), callback(); + } finally { + ReactCurrentBatchConfig$1.suspense = previousConfig; + } + }); +} function dispatchAction(fiber, queue, action) { if (!(25 > numberOfReRenders)) throw Error( @@ -3533,14 +3473,11 @@ function dispatchAction(fiber, queue, action) { eagerState: null, next: null }; - var last = queue.last; - if (null === last) suspenseConfig.next = suspenseConfig; - else { - var first = last.next; - null !== first && (suspenseConfig.next = first); - last.next = suspenseConfig; - } - queue.last = suspenseConfig; + var pending = queue.pending; + null === pending + ? (suspenseConfig.next = suspenseConfig) + : ((suspenseConfig.next = pending.next), (pending.next = suspenseConfig)); + queue.pending = suspenseConfig; if ( 0 === fiber.expirationTime && (null === alternate || 0 === alternate.expirationTime) && @@ -3603,7 +3540,7 @@ var ContextOnlyDispatcher = { initialArg = void 0 !== init ? init(initialArg) : initialArg; hook.memoizedState = hook.baseState = initialArg; reducer = hook.queue = { - last: null, + pending: null, dispatch: null, lastRenderedReducer: reducer, lastRenderedState: initialArg @@ -3622,23 +3559,21 @@ var ContextOnlyDispatcher = { }, useState: mountState, useDebugValue: mountDebugValue, - useResponder: createResponderListener, + useResponder: createDeprecatedResponderListener, useDeferredValue: function(value, config) { var _mountState = mountState(value), prevValue = _mountState[0], setValue = _mountState[1]; mountEffect( function() { - Scheduler.unstable_next(function() { - var previousConfig = ReactCurrentBatchConfig$1.suspense; - ReactCurrentBatchConfig$1.suspense = - void 0 === config ? null : config; - try { - setValue(value); - } finally { - ReactCurrentBatchConfig$1.suspense = previousConfig; - } - }); + var previousConfig = ReactCurrentBatchConfig$1.suspense; + ReactCurrentBatchConfig$1.suspense = + void 0 === config ? null : config; + try { + setValue(value); + } finally { + ReactCurrentBatchConfig$1.suspense = previousConfig; + } }, [value, config] ); @@ -3646,25 +3581,13 @@ var ContextOnlyDispatcher = { }, useTransition: function(config) { var _mountState2 = mountState(!1), - isPending = _mountState2[0], - setPending = _mountState2[1]; + isPending = _mountState2[0]; + _mountState2 = _mountState2[1]; return [ - mountCallback( - function(callback) { - setPending(!0); - Scheduler.unstable_next(function() { - var previousConfig = ReactCurrentBatchConfig$1.suspense; - ReactCurrentBatchConfig$1.suspense = - void 0 === config ? null : config; - try { - setPending(!1), callback(); - } finally { - ReactCurrentBatchConfig$1.suspense = previousConfig; - } - }); - }, - [config, isPending] - ), + mountCallback(startTransition.bind(null, _mountState2, config), [ + _mountState2, + config + ]), isPending ]; } @@ -3706,23 +3629,21 @@ var ContextOnlyDispatcher = { }, useState: updateState, useDebugValue: mountDebugValue, - useResponder: createResponderListener, + useResponder: createDeprecatedResponderListener, useDeferredValue: function(value, config) { var _updateState = updateState(value), prevValue = _updateState[0], setValue = _updateState[1]; updateEffect( function() { - Scheduler.unstable_next(function() { - var previousConfig = ReactCurrentBatchConfig$1.suspense; - ReactCurrentBatchConfig$1.suspense = - void 0 === config ? null : config; - try { - setValue(value); - } finally { - ReactCurrentBatchConfig$1.suspense = previousConfig; - } - }); + var previousConfig = ReactCurrentBatchConfig$1.suspense; + ReactCurrentBatchConfig$1.suspense = + void 0 === config ? null : config; + try { + setValue(value); + } finally { + ReactCurrentBatchConfig$1.suspense = previousConfig; + } }, [value, config] ); @@ -3730,25 +3651,13 @@ var ContextOnlyDispatcher = { }, useTransition: function(config) { var _updateState2 = updateState(!1), - isPending = _updateState2[0], - setPending = _updateState2[1]; + isPending = _updateState2[0]; + _updateState2 = _updateState2[1]; return [ - updateCallback( - function(callback) { - setPending(!0); - Scheduler.unstable_next(function() { - var previousConfig = ReactCurrentBatchConfig$1.suspense; - ReactCurrentBatchConfig$1.suspense = - void 0 === config ? null : config; - try { - setPending(!1), callback(); - } finally { - ReactCurrentBatchConfig$1.suspense = previousConfig; - } - }); - }, - [config, isPending] - ), + updateCallback(startTransition.bind(null, _updateState2, config), [ + _updateState2, + config + ]), isPending ]; } @@ -4062,17 +3971,14 @@ function updateClassComponent( )); hasForceUpdate = !1; var oldState = workInProgress.memoizedState; - oldContext = instance.state = oldState; - var updateQueue = workInProgress.updateQueue; - null !== updateQueue && - (processUpdateQueue( - workInProgress, - updateQueue, - nextProps, - instance, - renderExpirationTime - ), - (oldContext = workInProgress.memoizedState)); + instance.state = oldState; + processUpdateQueue( + workInProgress, + nextProps, + instance, + renderExpirationTime + ); + oldContext = workInProgress.memoizedState; oldProps !== nextProps || oldState !== oldContext || didPerformWorkStackCursor.current || @@ -4118,6 +4024,7 @@ function updateClassComponent( (nextProps = !1)); } else (instance = workInProgress.stateNode), + cloneUpdateQueue(current$$1, workInProgress), (oldProps = workInProgress.memoizedProps), (instance.props = workInProgress.type === workInProgress.elementType @@ -4146,17 +4053,14 @@ function updateClassComponent( )), (hasForceUpdate = !1), (oldContext = workInProgress.memoizedState), - (oldState = instance.state = oldContext), - (updateQueue = workInProgress.updateQueue), - null !== updateQueue && - (processUpdateQueue( - workInProgress, - updateQueue, - nextProps, - instance, - renderExpirationTime - ), - (oldState = workInProgress.memoizedState)), + (instance.state = oldContext), + processUpdateQueue( + workInProgress, + nextProps, + instance, + renderExpirationTime + ), + (oldState = workInProgress.memoizedState), oldProps !== nextProps || oldContext !== oldState || didPerformWorkStackCursor.current || @@ -4458,6 +4362,7 @@ function initSuspenseListRenderState( ? (workInProgress.memoizedState = { isBackwards: isBackwards, rendering: null, + renderingStartTime: 0, last: lastContentRow, tail: tail, tailExpiration: 0, @@ -4466,6 +4371,7 @@ function initSuspenseListRenderState( }) : ((renderState.isBackwards = isBackwards), (renderState.rendering = null), + (renderState.renderingStartTime = 0), (renderState.last = lastContentRow), (renderState.tail = tail), (renderState.tailExpiration = 0), @@ -4792,16 +4698,17 @@ updateHostComponent$1 = function(current, workInProgress, type, newProps) { } }; 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.effectTag |= 4)); + oldText !== newText + ? ((current = requiredContext(rootInstanceStackCursor.current)), + (oldText = requiredContext(contextStackCursor$1.current)), + (workInProgress.stateNode = createTextInstance( + newText, + current, + oldText, + workInProgress + )), + (workInProgress.effectTag |= 4)) + : (workInProgress.stateNode = current.stateNode); }; function cutOffTailIfNeeded(renderState, hasRenderedATailFallback) { switch (renderState.tailMode) { @@ -4827,51 +4734,361 @@ function cutOffTailIfNeeded(renderState, hasRenderedATailFallback) { : (_lastTailNode.sibling = null); } } -function unwindWork(workInProgress) { +function completeWork(current, workInProgress, renderExpirationTime$jscomp$0) { + 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 null; case 1: - isContextProvider(workInProgress.type) && popContext(workInProgress); - var effectTag = workInProgress.effectTag; - return effectTag & 4096 - ? ((workInProgress.effectTag = (effectTag & -4097) | 64), - workInProgress) - : null; + return ( + isContextProvider(workInProgress.type) && popContext(workInProgress), + null + ); case 3: - popHostContainer(workInProgress); - popTopLevelContextObject(workInProgress); - effectTag = workInProgress.effectTag; - if (0 !== (effectTag & 64)) - throw Error( - "The root failed to unmount after an error. This is likely a bug in React. Please file an issue." - ); - workInProgress.effectTag = (effectTag & -4097) | 64; - return workInProgress; - case 5: - return popHostContext(workInProgress), null; - case 13: return ( - pop(suspenseStackCursor, workInProgress), - (effectTag = workInProgress.effectTag), - effectTag & 4096 - ? ((workInProgress.effectTag = (effectTag & -4097) | 64), - workInProgress) - : null + popHostContainer(workInProgress), + popTopLevelContextObject(workInProgress), + (current = workInProgress.stateNode), + current.pendingContext && + ((current.context = current.pendingContext), + (current.pendingContext = null)), + updateHostContainer(workInProgress), + null ); - case 19: - return pop(suspenseStackCursor, workInProgress), null; - case 4: - return popHostContainer(workInProgress), null; - case 10: - return popProvider(workInProgress), null; - default: + case 5: + popHostContext(workInProgress); + var rootContainerInstance = requiredContext( + rootInstanceStackCursor.current + ); + renderExpirationTime$jscomp$0 = workInProgress.type; + if (null !== current && null != workInProgress.stateNode) + updateHostComponent$1( + current, + workInProgress, + renderExpirationTime$jscomp$0, + newProps, + rootContainerInstance + ), + current.ref !== workInProgress.ref && + (workInProgress.effectTag |= 128); + 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." + ); + return null; + } + requiredContext(contextStackCursor$1.current); + current = nextReactTag; + nextReactTag += 2; + renderExpirationTime$jscomp$0 = getViewConfigForType( + renderExpirationTime$jscomp$0 + ); + var updatePayload = diffProperties( + null, + emptyObject, + newProps, + renderExpirationTime$jscomp$0.validAttributes + ); + rootContainerInstance = createNode( + current, + renderExpirationTime$jscomp$0.uiViewClassName, + rootContainerInstance, + updatePayload, + workInProgress + ); + current = new ReactFabricHostComponent( + current, + renderExpirationTime$jscomp$0, + newProps, + workInProgress + ); + current = { node: rootContainerInstance, canonical: current }; + appendAllChildren(current, workInProgress, !1, !1); + workInProgress.stateNode = current; + null !== workInProgress.ref && (workInProgress.effectTag |= 128); + } return null; - } -} -function createCapturedValue(value, source) { - return { - value: value, - source: source, - stack: getStackByFiberInDevAndProd(source) + 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); + rootContainerInstance = requiredContext(contextStackCursor$1.current); + workInProgress.stateNode = createTextInstance( + newProps, + current, + rootContainerInstance, + workInProgress + ); + } + return null; + case 13: + pop(suspenseStackCursor, workInProgress); + newProps = workInProgress.memoizedState; + if (0 !== (workInProgress.effectTag & 64)) + return ( + (workInProgress.expirationTime = renderExpirationTime$jscomp$0), + workInProgress + ); + newProps = null !== newProps; + rootContainerInstance = !1; + null !== current && + ((renderExpirationTime$jscomp$0 = current.memoizedState), + (rootContainerInstance = null !== renderExpirationTime$jscomp$0), + newProps || + null === renderExpirationTime$jscomp$0 || + ((renderExpirationTime$jscomp$0 = current.child.sibling), + null !== renderExpirationTime$jscomp$0 && + ((updatePayload = workInProgress.firstEffect), + null !== updatePayload + ? ((workInProgress.firstEffect = renderExpirationTime$jscomp$0), + (renderExpirationTime$jscomp$0.nextEffect = updatePayload)) + : ((workInProgress.firstEffect = workInProgress.lastEffect = renderExpirationTime$jscomp$0), + (renderExpirationTime$jscomp$0.nextEffect = null)), + (renderExpirationTime$jscomp$0.effectTag = 8)))); + if (newProps && !rootContainerInstance && 0 !== (workInProgress.mode & 2)) + if ( + (null === current && + !0 !== workInProgress.memoizedProps.unstable_avoidThisFallback) || + 0 !== (suspenseStackCursor.current & 1) + ) + workInProgressRootExitStatus === RootIncomplete && + (workInProgressRootExitStatus = RootSuspended); + else { + if ( + workInProgressRootExitStatus === RootIncomplete || + workInProgressRootExitStatus === RootSuspended + ) + workInProgressRootExitStatus = RootSuspendedWithDelay; + 0 !== workInProgressRootNextUnprocessedUpdateTime && + null !== workInProgressRoot && + (markRootSuspendedAtTime(workInProgressRoot, renderExpirationTime), + markRootUpdatedAtTime( + workInProgressRoot, + workInProgressRootNextUnprocessedUpdateTime + )); + } + newProps && (workInProgress.effectTag |= 4); + return null; + case 4: + return ( + popHostContainer(workInProgress), + updateHostContainer(workInProgress), + null + ); + case 10: + return popProvider(workInProgress), null; + case 17: + return ( + isContextProvider(workInProgress.type) && popContext(workInProgress), + null + ); + case 19: + pop(suspenseStackCursor, workInProgress); + newProps = workInProgress.memoizedState; + if (null === newProps) return null; + rootContainerInstance = 0 !== (workInProgress.effectTag & 64); + updatePayload = newProps.rendering; + if (null === updatePayload) + if (rootContainerInstance) cutOffTailIfNeeded(newProps, !1); + else { + if ( + workInProgressRootExitStatus !== RootIncomplete || + (null !== current && 0 !== (current.effectTag & 64)) + ) + for (current = workInProgress.child; null !== current; ) { + updatePayload = findFirstSuspended(current); + if (null !== updatePayload) { + workInProgress.effectTag |= 64; + cutOffTailIfNeeded(newProps, !1); + current = updatePayload.updateQueue; + null !== current && + ((workInProgress.updateQueue = current), + (workInProgress.effectTag |= 4)); + null === newProps.lastEffect && + (workInProgress.firstEffect = null); + workInProgress.lastEffect = newProps.lastEffect; + current = renderExpirationTime$jscomp$0; + for (newProps = workInProgress.child; null !== newProps; ) + (rootContainerInstance = newProps), + (renderExpirationTime$jscomp$0 = current), + (rootContainerInstance.effectTag &= 2), + (rootContainerInstance.nextEffect = null), + (rootContainerInstance.firstEffect = null), + (rootContainerInstance.lastEffect = null), + (updatePayload = rootContainerInstance.alternate), + null === updatePayload + ? ((rootContainerInstance.childExpirationTime = 0), + (rootContainerInstance.expirationTime = renderExpirationTime$jscomp$0), + (rootContainerInstance.child = null), + (rootContainerInstance.memoizedProps = null), + (rootContainerInstance.memoizedState = null), + (rootContainerInstance.updateQueue = null), + (rootContainerInstance.dependencies = null)) + : ((rootContainerInstance.childExpirationTime = + updatePayload.childExpirationTime), + (rootContainerInstance.expirationTime = + updatePayload.expirationTime), + (rootContainerInstance.child = updatePayload.child), + (rootContainerInstance.memoizedProps = + updatePayload.memoizedProps), + (rootContainerInstance.memoizedState = + updatePayload.memoizedState), + (rootContainerInstance.updateQueue = + updatePayload.updateQueue), + (renderExpirationTime$jscomp$0 = + updatePayload.dependencies), + (rootContainerInstance.dependencies = + null === renderExpirationTime$jscomp$0 + ? null + : { + expirationTime: + renderExpirationTime$jscomp$0.expirationTime, + firstContext: + renderExpirationTime$jscomp$0.firstContext, + responders: + renderExpirationTime$jscomp$0.responders + })), + (newProps = newProps.sibling); + push( + suspenseStackCursor, + (suspenseStackCursor.current & 1) | 2, + workInProgress + ); + return workInProgress.child; + } + current = current.sibling; + } + } + else { + if (!rootContainerInstance) + if ( + ((current = findFirstSuspended(updatePayload)), null !== current) + ) { + if ( + ((workInProgress.effectTag |= 64), + (rootContainerInstance = !0), + (current = current.updateQueue), + null !== current && + ((workInProgress.updateQueue = current), + (workInProgress.effectTag |= 4)), + cutOffTailIfNeeded(newProps, !0), + null === newProps.tail && + "hidden" === newProps.tailMode && + !updatePayload.alternate) + ) + return ( + (workInProgress = workInProgress.lastEffect = + newProps.lastEffect), + null !== workInProgress && (workInProgress.nextEffect = null), + null + ); + } else + 2 * now() - newProps.renderingStartTime > newProps.tailExpiration && + 1 < renderExpirationTime$jscomp$0 && + ((workInProgress.effectTag |= 64), + (rootContainerInstance = !0), + cutOffTailIfNeeded(newProps, !1), + (workInProgress.expirationTime = workInProgress.childExpirationTime = + renderExpirationTime$jscomp$0 - 1)); + newProps.isBackwards + ? ((updatePayload.sibling = workInProgress.child), + (workInProgress.child = updatePayload)) + : ((current = newProps.last), + null !== current + ? (current.sibling = updatePayload) + : (workInProgress.child = updatePayload), + (newProps.last = updatePayload)); + } + return null !== newProps.tail + ? (0 === newProps.tailExpiration && + (newProps.tailExpiration = now() + 500), + (current = newProps.tail), + (newProps.rendering = current), + (newProps.tail = current.sibling), + (newProps.lastEffect = workInProgress.lastEffect), + (newProps.renderingStartTime = now()), + (current.sibling = null), + (newProps = suspenseStackCursor.current), + push( + suspenseStackCursor, + rootContainerInstance ? (newProps & 1) | 2 : newProps & 1, + workInProgress + ), + current) + : null; + } + throw 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) { + switch (workInProgress.tag) { + case 1: + isContextProvider(workInProgress.type) && popContext(workInProgress); + var effectTag = workInProgress.effectTag; + return effectTag & 4096 + ? ((workInProgress.effectTag = (effectTag & -4097) | 64), + workInProgress) + : null; + case 3: + popHostContainer(workInProgress); + popTopLevelContextObject(workInProgress); + effectTag = workInProgress.effectTag; + if (0 !== (effectTag & 64)) + throw Error( + "The root failed to unmount after an error. This is likely a bug in React. Please file an issue." + ); + workInProgress.effectTag = (effectTag & -4097) | 64; + return workInProgress; + case 5: + return popHostContext(workInProgress), null; + case 13: + return ( + pop(suspenseStackCursor, workInProgress), + (effectTag = workInProgress.effectTag), + effectTag & 4096 + ? ((workInProgress.effectTag = (effectTag & -4097) | 64), + workInProgress) + : null + ); + case 19: + return pop(suspenseStackCursor, workInProgress), null; + case 4: + return popHostContainer(workInProgress), null; + case 10: + return popProvider(workInProgress), null; + default: + return null; + } +} +function createCapturedValue(value, source) { + return { + value: value, + source: source, + stack: getStackByFiberInDevAndProd(source) }; } if ( @@ -4942,8 +5159,9 @@ function commitBeforeMutationLifeCycles(current$$1, finishedWork) { case 0: case 11: case 15: + case 22: commitHookEffectList(2, 0, finishedWork); - break; + return; case 1: if (finishedWork.effectTag & 256 && null !== current$$1) { var prevProps = current$$1.memoizedProps, @@ -4957,18 +5175,17 @@ function commitBeforeMutationLifeCycles(current$$1, finishedWork) { ); current$$1.__reactInternalSnapshotBeforeUpdate = finishedWork; } - break; + return; case 3: case 5: case 6: case 4: case 17: - 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." - ); + return; } + throw Error( + "This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue." + ); } function commitHookEffectList(unmountTag, mountTag, finishedWork) { finishedWork = finishedWork.updateQueue; @@ -4987,6 +5204,90 @@ function commitHookEffectList(unmountTag, mountTag, finishedWork) { } while (effect !== finishedWork); } } +function commitLifeCycles( + finishedRoot, + current$$1, + finishedWork, + committedExpirationTime +) { + switch (finishedWork.tag) { + case 0: + case 11: + case 15: + case 22: + commitHookEffectList(16, 32, finishedWork); + return; + case 1: + finishedRoot = finishedWork.stateNode; + if (finishedWork.effectTag & 4) + if (null === current$$1) finishedRoot.componentDidMount(); + else { + var prevProps = + finishedWork.elementType === finishedWork.type + ? current$$1.memoizedProps + : resolveDefaultProps( + finishedWork.type, + current$$1.memoizedProps + ); + finishedRoot.componentDidUpdate( + prevProps, + current$$1.memoizedState, + finishedRoot.__reactInternalSnapshotBeforeUpdate + ); + } + current$$1 = finishedWork.updateQueue; + null !== current$$1 && + commitUpdateQueue( + finishedWork, + current$$1, + finishedRoot, + committedExpirationTime + ); + return; + case 3: + current$$1 = finishedWork.updateQueue; + if (null !== current$$1) { + finishedRoot = null; + if (null !== finishedWork.child) + switch (finishedWork.child.tag) { + case 5: + finishedRoot = finishedWork.child.stateNode.canonical; + break; + case 1: + finishedRoot = finishedWork.child.stateNode; + } + commitUpdateQueue( + finishedWork, + current$$1, + finishedRoot, + committedExpirationTime + ); + } + return; + case 5: + if (null === current$$1 && finishedWork.effectTag & 4) + throw Error( + "The current renderer does not support mutation. This error is likely caused by a bug in React. Please file an issue." + ); + return; + case 6: + return; + case 4: + return; + case 12: + return; + case 13: + return; + case 19: + case 17: + case 20: + case 21: + return; + } + throw Error( + "This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue." + ); +} function commitUnmount(finishedRoot, current$$1$jscomp$0, renderPriorityLevel) { "function" === typeof onCommitFiberUnmount && onCommitFiberUnmount(current$$1$jscomp$0); @@ -4995,13 +5296,14 @@ function commitUnmount(finishedRoot, current$$1$jscomp$0, renderPriorityLevel) { case 11: case 14: case 15: + case 22: finishedRoot = current$$1$jscomp$0.updateQueue; if ( null !== finishedRoot && ((finishedRoot = finishedRoot.lastEffect), null !== finishedRoot) ) { var firstEffect = finishedRoot.next; - runWithPriority$1( + runWithPriority( 97 < renderPriorityLevel ? 97 : renderPriorityLevel, function() { var effect = firstEffect; @@ -5049,6 +5351,7 @@ function detachFiber(current$$1) { current$$1.lastEffect = null; current$$1.pendingProps = null; current$$1.memoizedProps = null; + current$$1.stateNode = null; null !== alternate && detachFiber(alternate); } function commitWork(current$$1, finishedWork) { @@ -5057,6 +5360,7 @@ function commitWork(current$$1, finishedWork) { case 11: case 14: case 15: + case 22: commitHookEffectList(4, 8, finishedWork); return; case 12: @@ -5070,19 +5374,20 @@ function commitWork(current$$1, finishedWork) { attachSuspenseRetryListeners(finishedWork); return; } - a: switch (finishedWork.tag) { - case 1: - case 5: - case 6: - case 20: - break a; - case 3: - case 4: - break a; - 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." - ); + a: { + switch (finishedWork.tag) { + case 1: + case 5: + case 6: + case 20: + break a; + case 3: + case 4: + break a; + } + throw Error( + "This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue." + ); } } function attachSuspenseRetryListeners(finishedWork) { @@ -5555,44 +5860,41 @@ function performConcurrentWorkOnRoot(root, didTimeout) { function performSyncWorkOnRoot(root) { var lastExpiredTime = root.lastExpiredTime; lastExpiredTime = 0 !== lastExpiredTime ? lastExpiredTime : 1073741823; - if (root.finishedExpirationTime === lastExpiredTime) commitRoot(root); - else { - if ((executionContext & (RenderContext | CommitContext)) !== NoContext) - throw Error("Should not already be working."); - flushPassiveEffects(); - (root === workInProgressRoot && lastExpiredTime === renderExpirationTime) || - prepareFreshStack(root, lastExpiredTime); - if (null !== workInProgress) { - var prevExecutionContext = executionContext; - executionContext |= RenderContext; - var prevDispatcher = pushDispatcher(root); - do - try { - workLoopSync(); - break; - } catch (thrownValue) { - handleError(root, thrownValue); - } - while (1); - resetContextDependencies(); - executionContext = prevExecutionContext; - ReactCurrentDispatcher.current = prevDispatcher; - if (workInProgressRootExitStatus === RootFatalErrored) - throw ((prevExecutionContext = workInProgressRootFatalError), - prepareFreshStack(root, lastExpiredTime), - markRootSuspendedAtTime(root, lastExpiredTime), - ensureRootIsScheduled(root), - prevExecutionContext); - if (null !== workInProgress) - throw Error( - "Cannot commit an incomplete root. This error is likely caused by a bug in React. Please file an issue." - ); - root.finishedWork = root.current.alternate; - root.finishedExpirationTime = lastExpiredTime; - workInProgressRoot = null; - commitRoot(root); - ensureRootIsScheduled(root); - } + if ((executionContext & (RenderContext | CommitContext)) !== NoContext) + throw Error("Should not already be working."); + flushPassiveEffects(); + (root === workInProgressRoot && lastExpiredTime === renderExpirationTime) || + prepareFreshStack(root, lastExpiredTime); + if (null !== workInProgress) { + var prevExecutionContext = executionContext; + executionContext |= RenderContext; + var prevDispatcher = pushDispatcher(root); + do + try { + workLoopSync(); + break; + } catch (thrownValue) { + handleError(root, thrownValue); + } + while (1); + resetContextDependencies(); + executionContext = prevExecutionContext; + ReactCurrentDispatcher.current = prevDispatcher; + if (workInProgressRootExitStatus === RootFatalErrored) + throw ((prevExecutionContext = workInProgressRootFatalError), + prepareFreshStack(root, lastExpiredTime), + markRootSuspendedAtTime(root, lastExpiredTime), + ensureRootIsScheduled(root), + prevExecutionContext); + if (null !== workInProgress) + throw Error( + "Cannot commit an incomplete root. This error is likely caused by a bug in React. Please file an issue." + ); + root.finishedWork = root.current.alternate; + root.finishedExpirationTime = lastExpiredTime; + workInProgressRoot = null; + commitRoot(root); + ensureRootIsScheduled(root); } return null; } @@ -5678,8 +5980,15 @@ function handleError(root$jscomp$0, thrownValue) { "object" === typeof value && "function" === typeof value.then ) { - var thenable = value, - hasInvisibleParentBoundary = + var thenable = value; + if (0 === (sourceFiber.mode & 2)) { + var currentSource = sourceFiber.alternate; + currentSource + ? ((sourceFiber.memoizedState = currentSource.memoizedState), + (sourceFiber.expirationTime = currentSource.expirationTime)) + : (sourceFiber.memoizedState = null); + } + var hasInvisibleParentBoundary = 0 !== (suspenseStackCursor.current & 1), _workInProgress = returnFiber; do { @@ -5847,346 +6156,30 @@ function completeUnitOfWork(unitOfWork) { var current$$1 = workInProgress.alternate; unitOfWork = workInProgress.return; if (0 === (workInProgress.effectTag & 2048)) { - a: { - var instance = current$$1; - current$$1 = workInProgress; - var renderExpirationTime$jscomp$0 = renderExpirationTime, - newProps = current$$1.pendingProps; - switch (current$$1.tag) { - case 2: - break; - case 16: - break; - case 15: - case 0: - break; - case 1: - isContextProvider(current$$1.type) && popContext(current$$1); - break; - case 3: - popHostContainer(current$$1); - popTopLevelContextObject(current$$1); - instance = current$$1.stateNode; - instance.pendingContext && - ((instance.context = instance.pendingContext), - (instance.pendingContext = null)); - updateHostContainer(current$$1); - break; - case 5: - popHostContext(current$$1); - var rootContainerInstance = requiredContext( - rootInstanceStackCursor.current - ), - type = current$$1.type; - if (null !== instance && null != current$$1.stateNode) - updateHostComponent$1( - instance, - current$$1, - type, - newProps, - rootContainerInstance - ), - instance.ref !== current$$1.ref && - (current$$1.effectTag |= 128); - else if (newProps) { - requiredContext(contextStackCursor$1.current); - instance = current$$1; - renderExpirationTime$jscomp$0 = nextReactTag; - nextReactTag += 2; - type = getViewConfigForType(type); - var updatePayload = diffProperties( - null, - emptyObject, - newProps, - type.validAttributes - ); - rootContainerInstance = createNode( - renderExpirationTime$jscomp$0, - type.uiViewClassName, - rootContainerInstance, - updatePayload, - instance - ); - instance = new ReactFabricHostComponent( - renderExpirationTime$jscomp$0, - type, - newProps, - instance - ); - instance = { - node: rootContainerInstance, - canonical: instance - }; - appendAllChildren(instance, current$$1, !1, !1); - current$$1.stateNode = instance; - null !== current$$1.ref && (current$$1.effectTag |= 128); - } else if (null === current$$1.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." - ); - break; - case 6: - if (instance && null != current$$1.stateNode) - updateHostText$1( - instance, - current$$1, - instance.memoizedProps, - newProps - ); - else { - if ("string" !== typeof newProps && null === current$$1.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." - ); - instance = requiredContext(rootInstanceStackCursor.current); - rootContainerInstance = requiredContext( - contextStackCursor$1.current - ); - current$$1.stateNode = createTextInstance( - newProps, - instance, - rootContainerInstance, - current$$1 - ); - } - break; - case 11: - break; - case 13: - pop(suspenseStackCursor, current$$1); - newProps = current$$1.memoizedState; - if (0 !== (current$$1.effectTag & 64)) { - current$$1.expirationTime = renderExpirationTime$jscomp$0; - break a; - } - newProps = null !== newProps; - rootContainerInstance = !1; - null !== instance && - ((renderExpirationTime$jscomp$0 = instance.memoizedState), - (rootContainerInstance = null !== renderExpirationTime$jscomp$0), - newProps || - null === renderExpirationTime$jscomp$0 || - ((renderExpirationTime$jscomp$0 = instance.child.sibling), - null !== renderExpirationTime$jscomp$0 && - ((type = current$$1.firstEffect), - null !== type - ? ((current$$1.firstEffect = renderExpirationTime$jscomp$0), - (renderExpirationTime$jscomp$0.nextEffect = type)) - : ((current$$1.firstEffect = current$$1.lastEffect = renderExpirationTime$jscomp$0), - (renderExpirationTime$jscomp$0.nextEffect = null)), - (renderExpirationTime$jscomp$0.effectTag = 8)))); - if ( - newProps && - !rootContainerInstance && - 0 !== (current$$1.mode & 2) - ) - if ( - (null === instance && - !0 !== current$$1.memoizedProps.unstable_avoidThisFallback) || - 0 !== (suspenseStackCursor.current & 1) - ) - workInProgressRootExitStatus === RootIncomplete && - (workInProgressRootExitStatus = RootSuspended); - else { - if ( - workInProgressRootExitStatus === RootIncomplete || - workInProgressRootExitStatus === RootSuspended - ) - workInProgressRootExitStatus = RootSuspendedWithDelay; - 0 !== workInProgressRootNextUnprocessedUpdateTime && - null !== workInProgressRoot && - (markRootSuspendedAtTime( - workInProgressRoot, - renderExpirationTime - ), - markRootUpdatedAtTime( - workInProgressRoot, - workInProgressRootNextUnprocessedUpdateTime - )); - } - newProps && (current$$1.effectTag |= 4); - break; - case 7: - break; - case 8: - break; - case 12: - break; - case 4: - popHostContainer(current$$1); - updateHostContainer(current$$1); - break; - case 10: - popProvider(current$$1); - break; - case 9: - break; - case 14: - break; - case 17: - isContextProvider(current$$1.type) && popContext(current$$1); - break; - case 19: - pop(suspenseStackCursor, current$$1); - newProps = current$$1.memoizedState; - if (null === newProps) break; - rootContainerInstance = 0 !== (current$$1.effectTag & 64); - type = newProps.rendering; - if (null === type) - if (rootContainerInstance) cutOffTailIfNeeded(newProps, !1); - else { - if ( - workInProgressRootExitStatus !== RootIncomplete || - (null !== instance && 0 !== (instance.effectTag & 64)) - ) - for (instance = current$$1.child; null !== instance; ) { - type = findFirstSuspended(instance); - if (null !== type) { - current$$1.effectTag |= 64; - cutOffTailIfNeeded(newProps, !1); - instance = type.updateQueue; - null !== instance && - ((current$$1.updateQueue = instance), - (current$$1.effectTag |= 4)); - null === newProps.lastEffect && - (current$$1.firstEffect = null); - current$$1.lastEffect = newProps.lastEffect; - instance = renderExpirationTime$jscomp$0; - for (newProps = current$$1.child; null !== newProps; ) - (rootContainerInstance = newProps), - (renderExpirationTime$jscomp$0 = instance), - (rootContainerInstance.effectTag &= 2), - (rootContainerInstance.nextEffect = null), - (rootContainerInstance.firstEffect = null), - (rootContainerInstance.lastEffect = null), - (type = rootContainerInstance.alternate), - null === type - ? ((rootContainerInstance.childExpirationTime = 0), - (rootContainerInstance.expirationTime = renderExpirationTime$jscomp$0), - (rootContainerInstance.child = null), - (rootContainerInstance.memoizedProps = null), - (rootContainerInstance.memoizedState = null), - (rootContainerInstance.updateQueue = null), - (rootContainerInstance.dependencies = null)) - : ((rootContainerInstance.childExpirationTime = - type.childExpirationTime), - (rootContainerInstance.expirationTime = - type.expirationTime), - (rootContainerInstance.child = type.child), - (rootContainerInstance.memoizedProps = - type.memoizedProps), - (rootContainerInstance.memoizedState = - type.memoizedState), - (rootContainerInstance.updateQueue = - type.updateQueue), - (renderExpirationTime$jscomp$0 = - type.dependencies), - (rootContainerInstance.dependencies = - null === renderExpirationTime$jscomp$0 - ? null - : { - expirationTime: - renderExpirationTime$jscomp$0.expirationTime, - firstContext: - renderExpirationTime$jscomp$0.firstContext, - responders: - renderExpirationTime$jscomp$0.responders - })), - (newProps = newProps.sibling); - push( - suspenseStackCursor, - (suspenseStackCursor.current & 1) | 2, - current$$1 - ); - current$$1 = current$$1.child; - break a; - } - instance = instance.sibling; - } - } - else { - if (!rootContainerInstance) - if ( - ((instance = findFirstSuspended(type)), null !== instance) - ) { - if ( - ((current$$1.effectTag |= 64), - (rootContainerInstance = !0), - (instance = instance.updateQueue), - null !== instance && - ((current$$1.updateQueue = instance), - (current$$1.effectTag |= 4)), - cutOffTailIfNeeded(newProps, !0), - null === newProps.tail && - "hidden" === newProps.tailMode && - !type.alternate) - ) { - current$$1 = current$$1.lastEffect = newProps.lastEffect; - null !== current$$1 && (current$$1.nextEffect = null); - break; - } - } else - now() > newProps.tailExpiration && - 1 < renderExpirationTime$jscomp$0 && - ((current$$1.effectTag |= 64), - (rootContainerInstance = !0), - cutOffTailIfNeeded(newProps, !1), - (current$$1.expirationTime = current$$1.childExpirationTime = - renderExpirationTime$jscomp$0 - 1)); - newProps.isBackwards - ? ((type.sibling = current$$1.child), (current$$1.child = type)) - : ((instance = newProps.last), - null !== instance - ? (instance.sibling = type) - : (current$$1.child = type), - (newProps.last = type)); - } - if (null !== newProps.tail) { - 0 === newProps.tailExpiration && - (newProps.tailExpiration = now() + 500); - instance = newProps.tail; - newProps.rendering = instance; - newProps.tail = instance.sibling; - newProps.lastEffect = current$$1.lastEffect; - instance.sibling = null; - newProps = suspenseStackCursor.current; - newProps = rootContainerInstance - ? (newProps & 1) | 2 - : newProps & 1; - push(suspenseStackCursor, newProps, current$$1); - current$$1 = instance; - break a; - } - break; - case 20: - break; - case 21: - break; - default: - throw Error( - "Unknown unit of work tag (" + - current$$1.tag + - "). This error is likely caused by a bug in React. Please file an issue." - ); - } - current$$1 = null; - } - instance = workInProgress; - if (1 === renderExpirationTime || 1 !== instance.childExpirationTime) { - newProps = 0; + current$$1 = completeWork( + current$$1, + workInProgress, + renderExpirationTime + ); + var completedWork = workInProgress; + if ( + 1 === renderExpirationTime || + 1 !== completedWork.childExpirationTime + ) { for ( - rootContainerInstance = instance.child; - null !== rootContainerInstance; + var newChildExpirationTime = 0, _child = completedWork.child; + null !== _child; - ) - (renderExpirationTime$jscomp$0 = - rootContainerInstance.expirationTime), - (type = rootContainerInstance.childExpirationTime), - renderExpirationTime$jscomp$0 > newProps && - (newProps = renderExpirationTime$jscomp$0), - type > newProps && (newProps = type), - (rootContainerInstance = rootContainerInstance.sibling); - instance.childExpirationTime = newProps; + ) { + var _childUpdateExpirationTime = _child.expirationTime, + _childChildExpirationTime = _child.childExpirationTime; + _childUpdateExpirationTime > newChildExpirationTime && + (newChildExpirationTime = _childUpdateExpirationTime); + _childChildExpirationTime > newChildExpirationTime && + (newChildExpirationTime = _childChildExpirationTime); + _child = _child.sibling; + } + completedWork.childExpirationTime = newChildExpirationTime; } if (null !== current$$1) return current$$1; null !== unitOfWork && @@ -6225,11 +6218,12 @@ function getRemainingExpirationTime(fiber) { } function commitRoot(root) { var renderPriorityLevel = getCurrentPriorityLevel(); - runWithPriority$1(99, commitRootImpl.bind(null, root, renderPriorityLevel)); + runWithPriority(99, commitRootImpl.bind(null, root, renderPriorityLevel)); return null; } function commitRootImpl(root$jscomp$1, renderPriorityLevel$jscomp$1) { - flushPassiveEffects(); + do flushPassiveEffects(); + while (null !== rootWithPendingPassiveEffects); if ((executionContext & (RenderContext | CommitContext)) !== NoContext) throw Error("Should not already be working."); var finishedWork = root$jscomp$1.finishedWork, @@ -6360,101 +6354,34 @@ function commitRootImpl(root$jscomp$1, renderPriorityLevel$jscomp$1) { nextEffect = remainingExpirationTimeBeforeCommit; do try { - for (effectTag = expirationTime; null !== nextEffect; ) { + for ( + effectTag = root$jscomp$1, current$$1 = expirationTime; + null !== nextEffect; + + ) { var effectTag$jscomp$0 = nextEffect.effectTag; - if (effectTag$jscomp$0 & 36) { - var current$$1$jscomp$1 = nextEffect.alternate; - current$$1 = nextEffect; - currentRef = effectTag; - switch (current$$1.tag) { - case 0: - case 11: - case 15: - commitHookEffectList(16, 32, current$$1); - break; - case 1: - var instance = current$$1.stateNode; - if (current$$1.effectTag & 4) - if (null === current$$1$jscomp$1) - instance.componentDidMount(); - else { - var prevProps = - current$$1.elementType === current$$1.type - ? current$$1$jscomp$1.memoizedProps - : resolveDefaultProps( - current$$1.type, - current$$1$jscomp$1.memoizedProps - ); - instance.componentDidUpdate( - prevProps, - current$$1$jscomp$1.memoizedState, - instance.__reactInternalSnapshotBeforeUpdate - ); - } - var updateQueue = current$$1.updateQueue; - null !== updateQueue && - commitUpdateQueue( - current$$1, - updateQueue, - instance, - currentRef - ); - break; - case 3: - var _updateQueue = current$$1.updateQueue; - if (null !== _updateQueue) { - root = null; - if (null !== current$$1.child) - switch (current$$1.child.tag) { - case 5: - root = current$$1.child.stateNode.canonical; - break; - case 1: - root = current$$1.child.stateNode; - } - commitUpdateQueue(current$$1, _updateQueue, root, currentRef); - } - break; - case 5: - if (null === current$$1$jscomp$1 && current$$1.effectTag & 4) - throw Error( - "The current renderer does not support mutation. This error is likely caused by a bug in React. Please file an issue." - ); - break; - case 6: - break; - case 4: - break; - case 12: - break; - case 13: - break; - case 19: - case 17: - case 20: - case 21: - 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." - ); - } - } + effectTag$jscomp$0 & 36 && + commitLifeCycles( + effectTag, + nextEffect.alternate, + nextEffect, + current$$1 + ); if (effectTag$jscomp$0 & 128) { - current$$1 = void 0; + currentRef = void 0; var ref = nextEffect.ref; if (null !== ref) { - var instance$jscomp$0 = nextEffect.stateNode; + var instance = nextEffect.stateNode; switch (nextEffect.tag) { case 5: - current$$1 = instance$jscomp$0.canonical; + currentRef = instance.canonical; break; default: - current$$1 = instance$jscomp$0; + currentRef = instance; } "function" === typeof ref - ? ref(current$$1) - : (ref.current = current$$1); + ? ref(currentRef) + : (ref.current = currentRef); } } nextEffect = nextEffect.nextEffect; @@ -6524,7 +6451,7 @@ function flushPassiveEffects() { ? 97 : pendingPassiveEffectsRenderPriority; pendingPassiveEffectsRenderPriority = 90; - return runWithPriority$1(priorityLevel, flushPassiveEffectsImpl); + return runWithPriority(priorityLevel, flushPassiveEffectsImpl); } } function flushPassiveEffectsImpl() { @@ -6543,6 +6470,7 @@ function flushPassiveEffectsImpl() { case 0: case 11: case 15: + case 22: commitHookEffectList(128, 0, finishedWork), commitHookEffectList(0, 64, finishedWork); } @@ -6752,6 +6680,7 @@ beginWork$$1 = function(current$$1, workInProgress, renderExpirationTime) { null !== renderState.state && void 0 !== renderState.state ? renderState.state : null; + initializeUpdateQueue(workInProgress); var getDerivedStateFromProps = updateExpirationTime.getDerivedStateFromProps; "function" === typeof getDerivedStateFromProps && @@ -6789,62 +6718,63 @@ beginWork$$1 = function(current$$1, workInProgress, renderExpirationTime) { (workInProgress = workInProgress.child); return workInProgress; case 16: - renderState = workInProgress.elementType; - null !== current$$1 && - ((current$$1.alternate = null), - (workInProgress.alternate = null), - (workInProgress.effectTag |= 2)); - current$$1 = workInProgress.pendingProps; - initializeLazyComponentType(renderState); - if (1 !== renderState._status) throw renderState._result; - renderState = renderState._result; - workInProgress.type = renderState; - hasContext = workInProgress.tag = resolveLazyComponentTag(renderState); - current$$1 = resolveDefaultProps(renderState, current$$1); - switch (hasContext) { - case 0: - workInProgress = updateFunctionComponent( - null, - workInProgress, - renderState, - current$$1, - renderExpirationTime - ); - break; - case 1: - workInProgress = updateClassComponent( - null, - workInProgress, - renderState, - current$$1, - renderExpirationTime - ); - break; - case 11: - workInProgress = updateForwardRef( - null, - workInProgress, - renderState, - current$$1, - renderExpirationTime - ); - break; - case 14: - workInProgress = updateMemoComponent( - null, - workInProgress, - renderState, - resolveDefaultProps(renderState.type, current$$1), - updateExpirationTime, - renderExpirationTime - ); - break; - default: - throw Error( - "Element type is invalid. Received a promise that resolves to: " + - renderState + - ". Lazy element type must resolve to a class or function." - ); + a: { + renderState = workInProgress.elementType; + null !== current$$1 && + ((current$$1.alternate = null), + (workInProgress.alternate = null), + (workInProgress.effectTag |= 2)); + current$$1 = workInProgress.pendingProps; + initializeLazyComponentType(renderState); + if (1 !== renderState._status) throw renderState._result; + renderState = renderState._result; + workInProgress.type = renderState; + hasContext = workInProgress.tag = resolveLazyComponentTag(renderState); + current$$1 = resolveDefaultProps(renderState, current$$1); + switch (hasContext) { + case 0: + workInProgress = updateFunctionComponent( + null, + workInProgress, + renderState, + current$$1, + renderExpirationTime + ); + break a; + case 1: + workInProgress = updateClassComponent( + null, + workInProgress, + renderState, + current$$1, + renderExpirationTime + ); + break a; + case 11: + workInProgress = updateForwardRef( + null, + workInProgress, + renderState, + current$$1, + renderExpirationTime + ); + break a; + case 14: + workInProgress = updateMemoComponent( + null, + workInProgress, + renderState, + resolveDefaultProps(renderState.type, current$$1), + updateExpirationTime, + renderExpirationTime + ); + break a; + } + throw Error( + "Element type is invalid. Received a promise that resolves to: " + + renderState + + ". Lazy element type must resolve to a class or function." + ); } return workInProgress; case 0: @@ -6882,16 +6812,17 @@ beginWork$$1 = function(current$$1, workInProgress, renderExpirationTime) { case 3: pushHostRootContext(workInProgress); updateExpirationTime = workInProgress.updateQueue; - if (null === updateExpirationTime) + if (null === current$$1 || null === updateExpirationTime) throw Error( "If the root does not have an updateQueue, we should have already bailed out. This error is likely caused by a bug in React. Please file an issue." ); + updateExpirationTime = workInProgress.pendingProps; renderState = workInProgress.memoizedState; renderState = null !== renderState ? renderState.element : null; + cloneUpdateQueue(current$$1, workInProgress); processUpdateQueue( workInProgress, updateExpirationTime, - workInProgress.pendingProps, null, renderExpirationTime ); @@ -7375,6 +7306,9 @@ function createFiberFromTypeAndProps( fiberTag = 16; owner = null; break a; + case REACT_CHUNK_TYPE: + fiberTag = 22; + break a; } throw Error( "Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: " + @@ -7550,7 +7484,11 @@ function createPortal(children, containerInfo, implementation) { implementation: implementation }; } -var fabricDispatchCommand = nativeFabricUIManager.dispatchCommand; +function _inheritsLoose(subClass, superClass) { + subClass.prototype = Object.create(superClass.prototype); + subClass.prototype.constructor = subClass; + subClass.__proto__ = superClass; +} function findNodeHandle(componentOrHandle) { if (null == componentOrHandle) return null; if ("number" === typeof componentOrHandle) return componentOrHandle; @@ -7691,12 +7629,17 @@ var roots = new Map(), findNodeHandle: findNodeHandle, dispatchCommand: function(handle, command, args) { null != handle._nativeTag && - null != handle._internalInstanceHandle && - fabricDispatchCommand( - handle._internalInstanceHandle.stateNode.node, - command, - args - ); + (handle._internalInstanceHandle + ? nativeFabricUIManager.dispatchCommand( + handle._internalInstanceHandle.stateNode.node, + command, + args + ) + : ReactNativePrivateInterface.UIManager.dispatchViewManagerCommand( + handle._nativeTag, + command, + args + )); }, render: function(element, containerTag, callback) { var root = roots.get(containerTag); @@ -7705,6 +7648,7 @@ var roots = new Map(), var uninitializedFiber = createFiber(3, null, null, 0); root.current = uninitializedFiber; uninitializedFiber.stateNode = root; + initializeUpdateQueue(uninitializedFiber); roots.set(containerTag, root); } updateContainer(element, root, null, callback); @@ -7854,7 +7798,7 @@ var roots = new Map(), throw Error("getInspectorDataForViewTag() is not available in production"); }, bundleType: 0, - version: "16.11.0", + version: "16.12.0-19f6fe170", rendererPackageName: "react-native-renderer" }); var ReactFabric$2 = { default: ReactFabric }, diff --git a/Libraries/Renderer/implementations/ReactFabric-profiling.fb.js b/Libraries/Renderer/implementations/ReactFabric-profiling.fb.js index 90b9fe4a0821c5..d65855f6d93cbd 100644 --- a/Libraries/Renderer/implementations/ReactFabric-profiling.fb.js +++ b/Libraries/Renderer/implementations/ReactFabric-profiling.fb.js @@ -503,53 +503,27 @@ function recordTouchStart(touch) { } function recordTouchMove(touch) { var touchRecord = touchBank[getTouchIdentifier(touch)]; - touchRecord - ? ((touchRecord.touchActive = !0), - (touchRecord.previousPageX = touchRecord.currentPageX), - (touchRecord.previousPageY = touchRecord.currentPageY), - (touchRecord.previousTimeStamp = touchRecord.currentTimeStamp), - (touchRecord.currentPageX = touch.pageX), - (touchRecord.currentPageY = touch.pageY), - (touchRecord.currentTimeStamp = timestampForTouch(touch)), - (touchHistory.mostRecentTimeStamp = timestampForTouch(touch))) - : console.warn( - "Cannot record touch move without a touch start.\nTouch Move: %s\n", - "Touch Bank: %s", - printTouch(touch), - printTouchBank() - ); + touchRecord && + ((touchRecord.touchActive = !0), + (touchRecord.previousPageX = touchRecord.currentPageX), + (touchRecord.previousPageY = touchRecord.currentPageY), + (touchRecord.previousTimeStamp = touchRecord.currentTimeStamp), + (touchRecord.currentPageX = touch.pageX), + (touchRecord.currentPageY = touch.pageY), + (touchRecord.currentTimeStamp = timestampForTouch(touch)), + (touchHistory.mostRecentTimeStamp = timestampForTouch(touch))); } function recordTouchEnd(touch) { var touchRecord = touchBank[getTouchIdentifier(touch)]; - touchRecord - ? ((touchRecord.touchActive = !1), - (touchRecord.previousPageX = touchRecord.currentPageX), - (touchRecord.previousPageY = touchRecord.currentPageY), - (touchRecord.previousTimeStamp = touchRecord.currentTimeStamp), - (touchRecord.currentPageX = touch.pageX), - (touchRecord.currentPageY = touch.pageY), - (touchRecord.currentTimeStamp = timestampForTouch(touch)), - (touchHistory.mostRecentTimeStamp = timestampForTouch(touch))) - : console.warn( - "Cannot record touch end without a touch start.\nTouch End: %s\n", - "Touch Bank: %s", - printTouch(touch), - printTouchBank() - ); -} -function printTouch(touch) { - return JSON.stringify({ - identifier: touch.identifier, - pageX: touch.pageX, - pageY: touch.pageY, - timestamp: timestampForTouch(touch) - }); -} -function printTouchBank() { - var printed = JSON.stringify(touchBank.slice(0, 20)); - 20 < touchBank.length && - (printed += " (original size: " + touchBank.length + ")"); - return printed; + touchRecord && + ((touchRecord.touchActive = !1), + (touchRecord.previousPageX = touchRecord.currentPageX), + (touchRecord.previousPageY = touchRecord.currentPageY), + (touchRecord.previousTimeStamp = touchRecord.currentTimeStamp), + (touchRecord.currentPageX = touch.pageX), + (touchRecord.currentPageY = touch.pageY), + (touchRecord.currentTimeStamp = timestampForTouch(touch)), + (touchHistory.mostRecentTimeStamp = timestampForTouch(touch))); } var ResponderTouchHistoryStore = { recordTouchTrack: function(topLevelType, nativeEvent) { @@ -682,13 +656,7 @@ var eventTypes = { "topTouchCancel" === topLevelType ) if (0 <= trackedTouchCount) --trackedTouchCount; - else - return ( - console.warn( - "Ended a touch event which was not counted in `trackedTouchCount`." - ), - null - ); + else return null; ResponderTouchHistoryStore.recordTouchTrack(topLevelType, nativeEvent); if ( targetInst && @@ -1043,7 +1011,8 @@ var hasSymbol = "function" === typeof Symbol && Symbol.for, ? Symbol.for("react.suspense_list") : 60120, REACT_MEMO_TYPE = hasSymbol ? Symbol.for("react.memo") : 60115, - REACT_LAZY_TYPE = hasSymbol ? Symbol.for("react.lazy") : 60116; + REACT_LAZY_TYPE = hasSymbol ? Symbol.for("react.lazy") : 60116, + REACT_CHUNK_TYPE = hasSymbol ? Symbol.for("react.chunk") : 60121; hasSymbol && Symbol.for("react.fundamental"); hasSymbol && Symbol.for("react.responder"); hasSymbol && Symbol.for("react.scope"); @@ -1108,6 +1077,8 @@ function getComponentName(type) { ); case REACT_MEMO_TYPE: return getComponentName(type.type); + case REACT_CHUNK_TYPE: + return getComponentName(type.render); case REACT_LAZY_TYPE: if ((type = 1 === type._status ? type._result : null)) return getComponentName(type); @@ -1495,26 +1466,6 @@ function batchedUpdates(fn, bookkeeping) { restoreStateOfTarget(fn[bookkeeping]); } } -function _inheritsLoose(subClass, superClass) { - subClass.prototype = Object.create(superClass.prototype); - subClass.prototype.constructor = subClass; - subClass.__proto__ = superClass; -} -(function(_React$Component) { - function ReactNativeComponent() { - return _React$Component.apply(this, arguments) || this; - } - _inheritsLoose(ReactNativeComponent, _React$Component); - var _proto = ReactNativeComponent.prototype; - _proto.blur = function() {}; - _proto.focus = function() {}; - _proto.measure = function() {}; - _proto.measureInWindow = function() {}; - _proto.measureLayout = function() {}; - _proto.setNativeProps = function() {}; - return ReactNativeComponent; -})(React.Component); -new Map(); function dispatchEvent(target, topLevelType, nativeEvent) { var eventTarget = null; enableNativeTargetAsInstance @@ -1557,21 +1508,21 @@ function shim$1() { "The current renderer does not support hydration. This error is likely caused by a bug in React. Please file an issue." ); } -var _nativeFabricUIManage$1 = nativeFabricUIManager, - createNode = _nativeFabricUIManage$1.createNode, - cloneNode = _nativeFabricUIManage$1.cloneNode, - cloneNodeWithNewChildren = _nativeFabricUIManage$1.cloneNodeWithNewChildren, +var _nativeFabricUIManage = nativeFabricUIManager, + createNode = _nativeFabricUIManage.createNode, + cloneNode = _nativeFabricUIManage.cloneNode, + cloneNodeWithNewChildren = _nativeFabricUIManage.cloneNodeWithNewChildren, cloneNodeWithNewChildrenAndProps = - _nativeFabricUIManage$1.cloneNodeWithNewChildrenAndProps, - cloneNodeWithNewProps = _nativeFabricUIManage$1.cloneNodeWithNewProps, - createChildNodeSet = _nativeFabricUIManage$1.createChildSet, - appendChildNode = _nativeFabricUIManage$1.appendChild, - appendChildNodeToSet = _nativeFabricUIManage$1.appendChildToSet, - completeRoot = _nativeFabricUIManage$1.completeRoot, - registerEventHandler = _nativeFabricUIManage$1.registerEventHandler, - fabricMeasure = _nativeFabricUIManage$1.measure, - fabricMeasureInWindow = _nativeFabricUIManage$1.measureInWindow, - fabricMeasureLayout = _nativeFabricUIManage$1.measureLayout, + _nativeFabricUIManage.cloneNodeWithNewChildrenAndProps, + cloneNodeWithNewProps = _nativeFabricUIManage.cloneNodeWithNewProps, + createChildNodeSet = _nativeFabricUIManage.createChildSet, + appendChildNode = _nativeFabricUIManage.appendChild, + appendChildNodeToSet = _nativeFabricUIManage.appendChildToSet, + completeRoot = _nativeFabricUIManage.completeRoot, + registerEventHandler = _nativeFabricUIManage.registerEventHandler, + fabricMeasure = _nativeFabricUIManage.measure, + fabricMeasureInWindow = _nativeFabricUIManage.measureInWindow, + fabricMeasureLayout = _nativeFabricUIManage.measureLayout, getViewConfigForType = ReactNativePrivateInterface.ReactNativeViewConfigRegistry.get, nextReactTag = 2; @@ -1855,7 +1806,7 @@ function reactPriorityToSchedulerPriority(reactPriorityLevel) { throw Error("Unknown priority level."); } } -function runWithPriority$1(reactPriorityLevel, fn) { +function runWithPriority(reactPriorityLevel, fn) { reactPriorityLevel = reactPriorityToSchedulerPriority(reactPriorityLevel); return Scheduler_runWithPriority(reactPriorityLevel, fn); } @@ -1887,7 +1838,7 @@ function flushSyncCallbackQueueImpl() { var i = 0; try { var queue = syncQueue; - runWithPriority$1(99, function() { + runWithPriority(99, function() { for (; i < queue.length; i++) { var callback = queue[i]; do callback = callback(!0); @@ -2024,237 +1975,195 @@ function readContext(context, observedBits) { return context._currentValue2; } var hasForceUpdate = !1; -function createUpdateQueue(baseState) { - return { - baseState: baseState, - firstUpdate: null, - lastUpdate: null, - firstCapturedUpdate: null, - lastCapturedUpdate: null, - firstEffect: null, - lastEffect: null, - firstCapturedEffect: null, - lastCapturedEffect: null +function initializeUpdateQueue(fiber) { + fiber.updateQueue = { + baseState: fiber.memoizedState, + baseQueue: null, + shared: { pending: null }, + effects: null }; } -function cloneUpdateQueue(currentQueue) { - return { - baseState: currentQueue.baseState, - firstUpdate: currentQueue.firstUpdate, - lastUpdate: currentQueue.lastUpdate, - firstCapturedUpdate: null, - lastCapturedUpdate: null, - firstEffect: null, - lastEffect: null, - firstCapturedEffect: null, - lastCapturedEffect: null - }; +function cloneUpdateQueue(current, workInProgress) { + current = current.updateQueue; + workInProgress.updateQueue === current && + (workInProgress.updateQueue = { + baseState: current.baseState, + baseQueue: current.baseQueue, + shared: current.shared, + effects: current.effects + }); } function createUpdate(expirationTime, suspenseConfig) { - return { + expirationTime = { expirationTime: expirationTime, suspenseConfig: suspenseConfig, tag: 0, payload: null, callback: null, - next: null, - nextEffect: null + next: null }; -} -function appendUpdateToQueue(queue, update) { - null === queue.lastUpdate - ? (queue.firstUpdate = queue.lastUpdate = update) - : ((queue.lastUpdate.next = update), (queue.lastUpdate = update)); + return (expirationTime.next = expirationTime); } function enqueueUpdate(fiber, update) { - var alternate = fiber.alternate; - if (null === alternate) { - var queue1 = fiber.updateQueue; - var queue2 = null; - null === queue1 && - (queue1 = fiber.updateQueue = createUpdateQueue(fiber.memoizedState)); - } else - (queue1 = fiber.updateQueue), - (queue2 = alternate.updateQueue), - null === queue1 - ? null === queue2 - ? ((queue1 = fiber.updateQueue = createUpdateQueue( - fiber.memoizedState - )), - (queue2 = alternate.updateQueue = createUpdateQueue( - alternate.memoizedState - ))) - : (queue1 = fiber.updateQueue = cloneUpdateQueue(queue2)) - : null === queue2 && - (queue2 = alternate.updateQueue = cloneUpdateQueue(queue1)); - null === queue2 || queue1 === queue2 - ? appendUpdateToQueue(queue1, update) - : null === queue1.lastUpdate || null === queue2.lastUpdate - ? (appendUpdateToQueue(queue1, update), - appendUpdateToQueue(queue2, update)) - : (appendUpdateToQueue(queue1, update), (queue2.lastUpdate = update)); + fiber = fiber.updateQueue; + if (null !== fiber) { + fiber = fiber.shared; + var pending = fiber.pending; + null === pending + ? (update.next = update) + : ((update.next = pending.next), (pending.next = update)); + fiber.pending = update; + } } function enqueueCapturedUpdate(workInProgress, update) { - var workInProgressQueue = workInProgress.updateQueue; - workInProgressQueue = - null === workInProgressQueue - ? (workInProgress.updateQueue = createUpdateQueue( - workInProgress.memoizedState - )) - : ensureWorkInProgressQueueIsAClone(workInProgress, workInProgressQueue); - null === workInProgressQueue.lastCapturedUpdate - ? (workInProgressQueue.firstCapturedUpdate = workInProgressQueue.lastCapturedUpdate = update) - : ((workInProgressQueue.lastCapturedUpdate.next = update), - (workInProgressQueue.lastCapturedUpdate = update)); -} -function ensureWorkInProgressQueueIsAClone(workInProgress, queue) { var current = workInProgress.alternate; - null !== current && - queue === current.updateQueue && - (queue = workInProgress.updateQueue = cloneUpdateQueue(queue)); - return queue; -} -function getStateFromUpdate( - workInProgress, - queue, - update, - prevState, - nextProps, - instance -) { - switch (update.tag) { - case 1: - return ( - (workInProgress = update.payload), - "function" === typeof workInProgress - ? workInProgress.call(instance, prevState, nextProps) - : workInProgress - ); - case 3: - workInProgress.effectTag = (workInProgress.effectTag & -4097) | 64; - case 0: - workInProgress = update.payload; - nextProps = - "function" === typeof workInProgress - ? workInProgress.call(instance, prevState, nextProps) - : workInProgress; - if (null === nextProps || void 0 === nextProps) break; - return Object.assign({}, prevState, nextProps); - case 2: - hasForceUpdate = !0; - } - return prevState; + null !== current && cloneUpdateQueue(current, workInProgress); + workInProgress = workInProgress.updateQueue; + current = workInProgress.baseQueue; + null === current + ? ((workInProgress.baseQueue = update.next = update), + (update.next = update)) + : ((update.next = current.next), (current.next = update)); } function processUpdateQueue( - workInProgress, - queue, + workInProgress$jscomp$0, props, instance, renderExpirationTime ) { + var queue = workInProgress$jscomp$0.updateQueue; hasForceUpdate = !1; - queue = ensureWorkInProgressQueueIsAClone(workInProgress, queue); - for ( - var newBaseState = queue.baseState, - newFirstUpdate = null, - newExpirationTime = 0, - update = queue.firstUpdate, - resultState = newBaseState; - null !== update; - - ) { - var updateExpirationTime = update.expirationTime; - updateExpirationTime < renderExpirationTime - ? (null === newFirstUpdate && - ((newFirstUpdate = update), (newBaseState = resultState)), - newExpirationTime < updateExpirationTime && - (newExpirationTime = updateExpirationTime)) - : (markRenderEventTimeAndConfig( - updateExpirationTime, - update.suspenseConfig - ), - (resultState = getStateFromUpdate( - workInProgress, - queue, - update, - resultState, - props, - instance - )), - null !== update.callback && - ((workInProgress.effectTag |= 32), - (update.nextEffect = null), - null === queue.lastEffect - ? (queue.firstEffect = queue.lastEffect = update) - : ((queue.lastEffect.nextEffect = update), - (queue.lastEffect = update)))); - update = update.next; + var baseQueue = queue.baseQueue, + pendingQueue = queue.shared.pending; + if (null !== pendingQueue) { + if (null !== baseQueue) { + var baseFirst = baseQueue.next; + baseQueue.next = pendingQueue.next; + pendingQueue.next = baseFirst; + } + baseQueue = pendingQueue; + queue.shared.pending = null; + baseFirst = workInProgress$jscomp$0.alternate; + null !== baseFirst && + ((baseFirst = baseFirst.updateQueue), + null !== baseFirst && (baseFirst.baseQueue = pendingQueue)); } - updateExpirationTime = null; - for (update = queue.firstCapturedUpdate; null !== update; ) { - var _updateExpirationTime = update.expirationTime; - _updateExpirationTime < renderExpirationTime - ? (null === updateExpirationTime && - ((updateExpirationTime = update), - null === newFirstUpdate && (newBaseState = resultState)), - newExpirationTime < _updateExpirationTime && - (newExpirationTime = _updateExpirationTime)) - : ((resultState = getStateFromUpdate( - workInProgress, - queue, - update, - resultState, - props, - instance - )), - null !== update.callback && - ((workInProgress.effectTag |= 32), - (update.nextEffect = null), - null === queue.lastCapturedEffect - ? (queue.firstCapturedEffect = queue.lastCapturedEffect = update) - : ((queue.lastCapturedEffect.nextEffect = update), - (queue.lastCapturedEffect = update)))); - update = update.next; + if (null !== baseQueue) { + baseFirst = baseQueue.next; + var newState = queue.baseState, + newExpirationTime = 0, + newBaseState = null, + newBaseQueueFirst = null, + newBaseQueueLast = null; + if (null !== baseFirst) { + var update = baseFirst; + do { + pendingQueue = update.expirationTime; + if (pendingQueue < renderExpirationTime) { + var clone = { + expirationTime: update.expirationTime, + suspenseConfig: update.suspenseConfig, + tag: update.tag, + payload: update.payload, + callback: update.callback, + next: null + }; + null === newBaseQueueLast + ? ((newBaseQueueFirst = newBaseQueueLast = clone), + (newBaseState = newState)) + : (newBaseQueueLast = newBaseQueueLast.next = clone); + pendingQueue > newExpirationTime && + (newExpirationTime = pendingQueue); + } else { + null !== newBaseQueueLast && + (newBaseQueueLast = newBaseQueueLast.next = { + expirationTime: 1073741823, + suspenseConfig: update.suspenseConfig, + tag: update.tag, + payload: update.payload, + callback: update.callback, + next: null + }); + markRenderEventTimeAndConfig(pendingQueue, update.suspenseConfig); + a: { + var workInProgress = workInProgress$jscomp$0, + update$jscomp$0 = update; + pendingQueue = props; + clone = instance; + switch (update$jscomp$0.tag) { + case 1: + workInProgress = update$jscomp$0.payload; + if ("function" === typeof workInProgress) { + newState = workInProgress.call(clone, newState, pendingQueue); + break a; + } + newState = workInProgress; + break a; + case 3: + workInProgress.effectTag = + (workInProgress.effectTag & -4097) | 64; + case 0: + workInProgress = update$jscomp$0.payload; + pendingQueue = + "function" === typeof workInProgress + ? workInProgress.call(clone, newState, pendingQueue) + : workInProgress; + if (null === pendingQueue || void 0 === pendingQueue) break a; + newState = Object.assign({}, newState, pendingQueue); + break a; + case 2: + hasForceUpdate = !0; + } + } + null !== update.callback && + ((workInProgress$jscomp$0.effectTag |= 32), + (pendingQueue = queue.effects), + null === pendingQueue + ? (queue.effects = [update]) + : pendingQueue.push(update)); + } + update = update.next; + if (null === update || update === baseFirst) + if (((pendingQueue = queue.shared.pending), null === pendingQueue)) + break; + else + (update = baseQueue.next = pendingQueue.next), + (pendingQueue.next = baseFirst), + (queue.baseQueue = baseQueue = pendingQueue), + (queue.shared.pending = null); + } while (1); + } + null === newBaseQueueLast + ? (newBaseState = newState) + : (newBaseQueueLast.next = newBaseQueueFirst); + queue.baseState = newBaseState; + queue.baseQueue = newBaseQueueLast; + markUnprocessedUpdateTime(newExpirationTime); + workInProgress$jscomp$0.expirationTime = newExpirationTime; + workInProgress$jscomp$0.memoizedState = newState; } - null === newFirstUpdate && (queue.lastUpdate = null); - null === updateExpirationTime - ? (queue.lastCapturedUpdate = null) - : (workInProgress.effectTag |= 32); - null === newFirstUpdate && - null === updateExpirationTime && - (newBaseState = resultState); - queue.baseState = newBaseState; - queue.firstUpdate = newFirstUpdate; - queue.firstCapturedUpdate = updateExpirationTime; - markUnprocessedUpdateTime(newExpirationTime); - workInProgress.expirationTime = newExpirationTime; - workInProgress.memoizedState = resultState; } function commitUpdateQueue(finishedWork, finishedQueue, instance) { - null !== finishedQueue.firstCapturedUpdate && - (null !== finishedQueue.lastUpdate && - ((finishedQueue.lastUpdate.next = finishedQueue.firstCapturedUpdate), - (finishedQueue.lastUpdate = finishedQueue.lastCapturedUpdate)), - (finishedQueue.firstCapturedUpdate = finishedQueue.lastCapturedUpdate = null)); - commitUpdateEffects(finishedQueue.firstEffect, instance); - finishedQueue.firstEffect = finishedQueue.lastEffect = null; - commitUpdateEffects(finishedQueue.firstCapturedEffect, instance); - finishedQueue.firstCapturedEffect = finishedQueue.lastCapturedEffect = null; -} -function commitUpdateEffects(effect, instance) { - for (; null !== effect; ) { - var callback = effect.callback; - if (null !== callback) { - effect.callback = null; - if ("function" !== typeof callback) - throw Error( - "Invalid argument passed as callback. Expected a function. Instead received: " + - callback - ); - callback.call(instance); + finishedWork = finishedQueue.effects; + finishedQueue.effects = null; + if (null !== finishedWork) + for ( + finishedQueue = 0; + finishedQueue < finishedWork.length; + finishedQueue++ + ) { + var effect = finishedWork[finishedQueue], + callback = effect.callback; + if (null !== callback) { + effect.callback = null; + if ("function" !== typeof callback) + throw Error( + "Invalid argument passed as callback. Expected a function. Instead received: " + + callback + ); + callback.call(instance); + } } - effect = effect.nextEffect; - } } var ReactCurrentBatchConfig = ReactSharedInternals.ReactCurrentBatchConfig, emptyRefsObject = new React.Component().refs; @@ -2271,10 +2180,8 @@ function applyDerivedStateFromProps( ? ctor : Object.assign({}, ctor, getDerivedStateFromProps); workInProgress.memoizedState = getDerivedStateFromProps; - nextProps = workInProgress.updateQueue; - null !== nextProps && - 0 === workInProgress.expirationTime && - (nextProps.baseState = getDerivedStateFromProps); + 0 === workInProgress.expirationTime && + (workInProgress.updateQueue.baseState = getDerivedStateFromProps); } var classComponentUpdater = { isMounted: function(component) { @@ -2389,6 +2296,7 @@ function mountClassInstance( instance.props = newProps; instance.state = workInProgress.memoizedState; instance.refs = emptyRefsObject; + initializeUpdateQueue(workInProgress); var contextType = ctor.contextType; "object" === typeof contextType && null !== contextType ? (instance.context = readContext(contextType)) @@ -2396,16 +2304,8 @@ function mountClassInstance( ? previousContext : contextStackCursor.current), (instance.context = getMaskedContext(workInProgress, contextType))); - contextType = workInProgress.updateQueue; - null !== contextType && - (processUpdateQueue( - workInProgress, - contextType, - newProps, - instance, - renderExpirationTime - ), - (instance.state = workInProgress.memoizedState)); + processUpdateQueue(workInProgress, newProps, instance, renderExpirationTime); + instance.state = workInProgress.memoizedState; contextType = ctor.getDerivedStateFromProps; "function" === typeof contextType && (applyDerivedStateFromProps(workInProgress, ctor, contextType, newProps), @@ -2421,16 +2321,13 @@ function mountClassInstance( instance.UNSAFE_componentWillMount(), ctor !== instance.state && classComponentUpdater.enqueueReplaceState(instance, instance.state, null), - (contextType = workInProgress.updateQueue), - null !== contextType && - (processUpdateQueue( - workInProgress, - contextType, - newProps, - instance, - renderExpirationTime - ), - (instance.state = workInProgress.memoizedState))); + processUpdateQueue( + workInProgress, + newProps, + instance, + renderExpirationTime + ), + (instance.state = workInProgress.memoizedState)); "function" === typeof instance.componentDidMount && (workInProgress.effectTag |= 4); } @@ -2992,39 +2889,50 @@ function ChildReconciler(shouldTrackSideEffects) { null !== isUnkeyedTopLevelFragment; ) { - if (isUnkeyedTopLevelFragment.key === isObject) - if ( - 7 === isUnkeyedTopLevelFragment.tag - ? newChild.type === REACT_FRAGMENT_TYPE - : isUnkeyedTopLevelFragment.elementType === newChild.type - ) { - deleteRemainingChildren( - returnFiber, - isUnkeyedTopLevelFragment.sibling - ); - currentFirstChild = useFiber( - isUnkeyedTopLevelFragment, - newChild.type === REACT_FRAGMENT_TYPE - ? newChild.props.children - : newChild.props, - expirationTime - ); - currentFirstChild.ref = coerceRef( - returnFiber, - isUnkeyedTopLevelFragment, - newChild - ); - currentFirstChild.return = returnFiber; - returnFiber = currentFirstChild; - break a; - } else { - deleteRemainingChildren( - returnFiber, - isUnkeyedTopLevelFragment - ); - break; + if (isUnkeyedTopLevelFragment.key === isObject) { + switch (isUnkeyedTopLevelFragment.tag) { + case 7: + if (newChild.type === REACT_FRAGMENT_TYPE) { + deleteRemainingChildren( + returnFiber, + isUnkeyedTopLevelFragment.sibling + ); + currentFirstChild = useFiber( + isUnkeyedTopLevelFragment, + newChild.props.children, + expirationTime + ); + currentFirstChild.return = returnFiber; + returnFiber = currentFirstChild; + break a; + } + break; + default: + if ( + isUnkeyedTopLevelFragment.elementType === newChild.type + ) { + deleteRemainingChildren( + returnFiber, + isUnkeyedTopLevelFragment.sibling + ); + currentFirstChild = useFiber( + isUnkeyedTopLevelFragment, + newChild.props, + expirationTime + ); + currentFirstChild.ref = coerceRef( + returnFiber, + isUnkeyedTopLevelFragment, + newChild + ); + currentFirstChild.return = returnFiber; + returnFiber = currentFirstChild; + break a; + } } - else deleteChild(returnFiber, isUnkeyedTopLevelFragment); + deleteRemainingChildren(returnFiber, isUnkeyedTopLevelFragment); + break; + } else deleteChild(returnFiber, isUnkeyedTopLevelFragment); isUnkeyedTopLevelFragment = isUnkeyedTopLevelFragment.sibling; } newChild.type === REACT_FRAGMENT_TYPE @@ -3222,7 +3130,7 @@ function findFirstSuspended(row) { } return null; } -function createResponderListener(responder, props) { +function createDeprecatedResponderListener(responder, props) { return { responder: responder, props: props }; } var ReactCurrentDispatcher$1 = ReactSharedInternals.ReactCurrentDispatcher, @@ -3230,13 +3138,7 @@ var ReactCurrentDispatcher$1 = ReactSharedInternals.ReactCurrentDispatcher, renderExpirationTime$1 = 0, currentlyRenderingFiber$1 = null, currentHook = null, - nextCurrentHook = null, - firstWorkInProgressHook = null, workInProgressHook = null, - nextWorkInProgressHook = null, - remainingExpirationTime = 0, - componentUpdateQueue = null, - sideEffectTag = 0, didScheduleRenderPhaseUpdate = !1, renderPhaseUpdates = null, numberOfReRenders = 0; @@ -3256,53 +3158,45 @@ function renderWithHooks( workInProgress, Component, props, - refOrContext, + secondArg, nextRenderExpirationTime ) { renderExpirationTime$1 = nextRenderExpirationTime; currentlyRenderingFiber$1 = workInProgress; - nextCurrentHook = null !== current ? current.memoizedState : null; + workInProgress.memoizedState = null; + workInProgress.updateQueue = null; + workInProgress.expirationTime = 0; ReactCurrentDispatcher$1.current = - null === nextCurrentHook ? HooksDispatcherOnMount : HooksDispatcherOnUpdate; - workInProgress = Component(props, refOrContext); + null === current || null === current.memoizedState + ? HooksDispatcherOnMount + : HooksDispatcherOnUpdate; + current = Component(props, secondArg); if (didScheduleRenderPhaseUpdate) { do (didScheduleRenderPhaseUpdate = !1), (numberOfReRenders += 1), - (nextCurrentHook = null !== current ? current.memoizedState : null), - (nextWorkInProgressHook = firstWorkInProgressHook), - (componentUpdateQueue = workInProgressHook = currentHook = null), + (workInProgressHook = currentHook = null), + (workInProgress.updateQueue = null), (ReactCurrentDispatcher$1.current = HooksDispatcherOnUpdate), - (workInProgress = Component(props, refOrContext)); + (current = Component(props, secondArg)); while (didScheduleRenderPhaseUpdate); renderPhaseUpdates = null; numberOfReRenders = 0; } ReactCurrentDispatcher$1.current = ContextOnlyDispatcher; - current = currentlyRenderingFiber$1; - current.memoizedState = firstWorkInProgressHook; - current.expirationTime = remainingExpirationTime; - current.updateQueue = componentUpdateQueue; - current.effectTag |= sideEffectTag; - current = null !== currentHook && null !== currentHook.next; + workInProgress = null !== currentHook && null !== currentHook.next; renderExpirationTime$1 = 0; - nextWorkInProgressHook = workInProgressHook = firstWorkInProgressHook = nextCurrentHook = currentHook = currentlyRenderingFiber$1 = null; - remainingExpirationTime = 0; - componentUpdateQueue = null; - sideEffectTag = 0; - if (current) + workInProgressHook = currentHook = currentlyRenderingFiber$1 = null; + if (workInProgress) throw Error( "Rendered fewer hooks than expected. This may be caused by an accidental early return statement." ); - return workInProgress; + return current; } function resetHooks() { ReactCurrentDispatcher$1.current = ContextOnlyDispatcher; renderExpirationTime$1 = 0; - nextWorkInProgressHook = workInProgressHook = firstWorkInProgressHook = nextCurrentHook = currentHook = currentlyRenderingFiber$1 = null; - remainingExpirationTime = 0; - componentUpdateQueue = null; - sideEffectTag = 0; + workInProgressHook = currentHook = currentlyRenderingFiber$1 = null; didScheduleRenderPhaseUpdate = !1; renderPhaseUpdates = null; numberOfReRenders = 0; @@ -3311,37 +3205,42 @@ function mountWorkInProgressHook() { var hook = { memoizedState: null, baseState: null, + baseQueue: null, queue: null, - baseUpdate: null, next: null }; null === workInProgressHook - ? (firstWorkInProgressHook = workInProgressHook = hook) + ? (currentlyRenderingFiber$1.memoizedState = workInProgressHook = hook) : (workInProgressHook = workInProgressHook.next = hook); return workInProgressHook; } function updateWorkInProgressHook() { + if (null === currentHook) { + var nextCurrentHook = currentlyRenderingFiber$1.alternate; + nextCurrentHook = + null !== nextCurrentHook ? nextCurrentHook.memoizedState : null; + } else nextCurrentHook = currentHook.next; + var nextWorkInProgressHook = + null === workInProgressHook + ? currentlyRenderingFiber$1.memoizedState + : workInProgressHook.next; if (null !== nextWorkInProgressHook) (workInProgressHook = nextWorkInProgressHook), - (nextWorkInProgressHook = workInProgressHook.next), - (currentHook = nextCurrentHook), - (nextCurrentHook = null !== currentHook ? currentHook.next : null); + (currentHook = nextCurrentHook); else { if (null === nextCurrentHook) throw Error("Rendered more hooks than during the previous render."); currentHook = nextCurrentHook; - var newHook = { + nextCurrentHook = { memoizedState: currentHook.memoizedState, baseState: currentHook.baseState, + baseQueue: currentHook.baseQueue, queue: currentHook.queue, - baseUpdate: currentHook.baseUpdate, next: null }; - workInProgressHook = - null === workInProgressHook - ? (firstWorkInProgressHook = newHook) - : (workInProgressHook.next = newHook); - nextCurrentHook = currentHook.next; + null === workInProgressHook + ? (currentlyRenderingFiber$1.memoizedState = workInProgressHook = nextCurrentHook) + : (workInProgressHook = workInProgressHook.next = nextCurrentHook); } return workInProgressHook; } @@ -3369,51 +3268,75 @@ function updateReducer(reducer) { while (null !== firstRenderPhaseUpdate); is$1(newState, hook.memoizedState) || (didReceiveUpdate = !0); hook.memoizedState = newState; - hook.baseUpdate === queue.last && (hook.baseState = newState); + null === hook.baseQueue && (hook.baseState = newState); queue.lastRenderedState = newState; return [newState, _dispatch]; } } return [hook.memoizedState, _dispatch]; } - _dispatch = queue.last; - var baseUpdate = hook.baseUpdate; - newState = hook.baseState; - null !== baseUpdate - ? (null !== _dispatch && (_dispatch.next = null), - (_dispatch = baseUpdate.next)) - : (_dispatch = null !== _dispatch ? _dispatch.next : null); + newState = currentHook; + _dispatch = newState.baseQueue; + firstRenderPhaseUpdate = queue.pending; + if (null !== firstRenderPhaseUpdate) { + if (null !== _dispatch) { + var baseFirst = _dispatch.next; + _dispatch.next = firstRenderPhaseUpdate.next; + firstRenderPhaseUpdate.next = baseFirst; + } + newState.baseQueue = _dispatch = firstRenderPhaseUpdate; + queue.pending = null; + } if (null !== _dispatch) { - var newBaseUpdate = (firstRenderPhaseUpdate = null), - _update = _dispatch, - didSkip = !1; + _dispatch = _dispatch.next; + newState = newState.baseState; + var newBaseQueueLast = (baseFirst = firstRenderPhaseUpdate = null), + _update = _dispatch; do { var updateExpirationTime = _update.expirationTime; - updateExpirationTime < renderExpirationTime$1 - ? (didSkip || - ((didSkip = !0), - (newBaseUpdate = baseUpdate), - (firstRenderPhaseUpdate = newState)), - updateExpirationTime > remainingExpirationTime && - ((remainingExpirationTime = updateExpirationTime), - markUnprocessedUpdateTime(remainingExpirationTime))) - : (markRenderEventTimeAndConfig( + if (updateExpirationTime < renderExpirationTime$1) { + var clone = { + expirationTime: _update.expirationTime, + suspenseConfig: _update.suspenseConfig, + action: _update.action, + eagerReducer: _update.eagerReducer, + eagerState: _update.eagerState, + next: null + }; + null === newBaseQueueLast + ? ((baseFirst = newBaseQueueLast = clone), + (firstRenderPhaseUpdate = newState)) + : (newBaseQueueLast = newBaseQueueLast.next = clone); + updateExpirationTime > currentlyRenderingFiber$1.expirationTime && + ((currentlyRenderingFiber$1.expirationTime = updateExpirationTime), + markUnprocessedUpdateTime(updateExpirationTime)); + } else + null !== newBaseQueueLast && + (newBaseQueueLast = newBaseQueueLast.next = { + expirationTime: 1073741823, + suspenseConfig: _update.suspenseConfig, + action: _update.action, + eagerReducer: _update.eagerReducer, + eagerState: _update.eagerState, + next: null + }), + markRenderEventTimeAndConfig( updateExpirationTime, _update.suspenseConfig ), (newState = _update.eagerReducer === reducer ? _update.eagerState - : reducer(newState, _update.action))); - baseUpdate = _update; + : reducer(newState, _update.action)); _update = _update.next; } while (null !== _update && _update !== _dispatch); - didSkip || - ((newBaseUpdate = baseUpdate), (firstRenderPhaseUpdate = newState)); + null === newBaseQueueLast + ? (firstRenderPhaseUpdate = newState) + : (newBaseQueueLast.next = baseFirst); is$1(newState, hook.memoizedState) || (didReceiveUpdate = !0); hook.memoizedState = newState; - hook.baseUpdate = newBaseUpdate; hook.baseState = firstRenderPhaseUpdate; + hook.baseQueue = newBaseQueueLast; queue.lastRenderedState = newState; } return [hook.memoizedState, queue.dispatch]; @@ -3423,7 +3346,7 @@ function mountState(initialState) { "function" === typeof initialState && (initialState = initialState()); hook.memoizedState = hook.baseState = initialState; initialState = hook.queue = { - last: null, + pending: null, dispatch: null, lastRenderedReducer: basicStateReducer, lastRenderedState: initialState @@ -3440,21 +3363,23 @@ function updateState(initialState) { } function pushEffect(tag, create, destroy, deps) { tag = { tag: tag, create: create, destroy: destroy, deps: deps, next: null }; - null === componentUpdateQueue - ? ((componentUpdateQueue = { lastEffect: null }), - (componentUpdateQueue.lastEffect = tag.next = tag)) - : ((create = componentUpdateQueue.lastEffect), - null === create - ? (componentUpdateQueue.lastEffect = tag.next = tag) - : ((destroy = create.next), - (create.next = tag), - (tag.next = destroy), - (componentUpdateQueue.lastEffect = tag))); + create = currentlyRenderingFiber$1.updateQueue; + null === create + ? ((create = { lastEffect: null }), + (currentlyRenderingFiber$1.updateQueue = create), + (create.lastEffect = tag.next = tag)) + : ((destroy = create.lastEffect), + null === destroy + ? (create.lastEffect = tag.next = tag) + : ((deps = destroy.next), + (destroy.next = tag), + (tag.next = deps), + (create.lastEffect = tag))); return tag; } function mountEffectImpl(fiberEffectTag, hookEffectTag, create, deps) { var hook = mountWorkInProgressHook(); - sideEffectTag |= fiberEffectTag; + currentlyRenderingFiber$1.effectTag |= fiberEffectTag; hook.memoizedState = pushEffect( hookEffectTag, create, @@ -3474,7 +3399,7 @@ function updateEffectImpl(fiberEffectTag, hookEffectTag, create, deps) { return; } } - sideEffectTag |= fiberEffectTag; + currentlyRenderingFiber$1.effectTag |= fiberEffectTag; hook.memoizedState = pushEffect(hookEffectTag, create, destroy, deps); } function mountEffect(create, deps) { @@ -3522,6 +3447,21 @@ function updateCallback(callback, deps) { hook.memoizedState = [callback, deps]; return callback; } +function startTransition(setPending, config, callback) { + var priorityLevel = getCurrentPriorityLevel(); + runWithPriority(98 > priorityLevel ? 98 : priorityLevel, function() { + setPending(!0); + }); + runWithPriority(97 < priorityLevel ? 97 : priorityLevel, function() { + var previousConfig = ReactCurrentBatchConfig$1.suspense; + ReactCurrentBatchConfig$1.suspense = void 0 === config ? null : config; + try { + setPending(!1), callback(); + } finally { + ReactCurrentBatchConfig$1.suspense = previousConfig; + } + }); +} function dispatchAction(fiber, queue, action) { if (!(25 > numberOfReRenders)) throw Error( @@ -3563,14 +3503,11 @@ function dispatchAction(fiber, queue, action) { eagerState: null, next: null }; - var last = queue.last; - if (null === last) suspenseConfig.next = suspenseConfig; - else { - var first = last.next; - null !== first && (suspenseConfig.next = first); - last.next = suspenseConfig; - } - queue.last = suspenseConfig; + var pending = queue.pending; + null === pending + ? (suspenseConfig.next = suspenseConfig) + : ((suspenseConfig.next = pending.next), (pending.next = suspenseConfig)); + queue.pending = suspenseConfig; if ( 0 === fiber.expirationTime && (null === alternate || 0 === alternate.expirationTime) && @@ -3633,7 +3570,7 @@ var ContextOnlyDispatcher = { initialArg = void 0 !== init ? init(initialArg) : initialArg; hook.memoizedState = hook.baseState = initialArg; reducer = hook.queue = { - last: null, + pending: null, dispatch: null, lastRenderedReducer: reducer, lastRenderedState: initialArg @@ -3652,23 +3589,21 @@ var ContextOnlyDispatcher = { }, useState: mountState, useDebugValue: mountDebugValue, - useResponder: createResponderListener, + useResponder: createDeprecatedResponderListener, useDeferredValue: function(value, config) { var _mountState = mountState(value), prevValue = _mountState[0], setValue = _mountState[1]; mountEffect( function() { - Scheduler.unstable_next(function() { - var previousConfig = ReactCurrentBatchConfig$1.suspense; - ReactCurrentBatchConfig$1.suspense = - void 0 === config ? null : config; - try { - setValue(value); - } finally { - ReactCurrentBatchConfig$1.suspense = previousConfig; - } - }); + var previousConfig = ReactCurrentBatchConfig$1.suspense; + ReactCurrentBatchConfig$1.suspense = + void 0 === config ? null : config; + try { + setValue(value); + } finally { + ReactCurrentBatchConfig$1.suspense = previousConfig; + } }, [value, config] ); @@ -3676,25 +3611,13 @@ var ContextOnlyDispatcher = { }, useTransition: function(config) { var _mountState2 = mountState(!1), - isPending = _mountState2[0], - setPending = _mountState2[1]; + isPending = _mountState2[0]; + _mountState2 = _mountState2[1]; return [ - mountCallback( - function(callback) { - setPending(!0); - Scheduler.unstable_next(function() { - var previousConfig = ReactCurrentBatchConfig$1.suspense; - ReactCurrentBatchConfig$1.suspense = - void 0 === config ? null : config; - try { - setPending(!1), callback(); - } finally { - ReactCurrentBatchConfig$1.suspense = previousConfig; - } - }); - }, - [config, isPending] - ), + mountCallback(startTransition.bind(null, _mountState2, config), [ + _mountState2, + config + ]), isPending ]; } @@ -3736,23 +3659,21 @@ var ContextOnlyDispatcher = { }, useState: updateState, useDebugValue: mountDebugValue, - useResponder: createResponderListener, + useResponder: createDeprecatedResponderListener, useDeferredValue: function(value, config) { var _updateState = updateState(value), prevValue = _updateState[0], setValue = _updateState[1]; updateEffect( function() { - Scheduler.unstable_next(function() { - var previousConfig = ReactCurrentBatchConfig$1.suspense; - ReactCurrentBatchConfig$1.suspense = - void 0 === config ? null : config; - try { - setValue(value); - } finally { - ReactCurrentBatchConfig$1.suspense = previousConfig; - } - }); + var previousConfig = ReactCurrentBatchConfig$1.suspense; + ReactCurrentBatchConfig$1.suspense = + void 0 === config ? null : config; + try { + setValue(value); + } finally { + ReactCurrentBatchConfig$1.suspense = previousConfig; + } }, [value, config] ); @@ -3760,25 +3681,13 @@ var ContextOnlyDispatcher = { }, useTransition: function(config) { var _updateState2 = updateState(!1), - isPending = _updateState2[0], - setPending = _updateState2[1]; + isPending = _updateState2[0]; + _updateState2 = _updateState2[1]; return [ - updateCallback( - function(callback) { - setPending(!0); - Scheduler.unstable_next(function() { - var previousConfig = ReactCurrentBatchConfig$1.suspense; - ReactCurrentBatchConfig$1.suspense = - void 0 === config ? null : config; - try { - setPending(!1), callback(); - } finally { - ReactCurrentBatchConfig$1.suspense = previousConfig; - } - }); - }, - [config, isPending] - ), + updateCallback(startTransition.bind(null, _updateState2, config), [ + _updateState2, + config + ]), isPending ]; } @@ -4103,17 +4012,14 @@ function updateClassComponent( )); hasForceUpdate = !1; var oldState = workInProgress.memoizedState; - oldContext = instance.state = oldState; - var updateQueue = workInProgress.updateQueue; - null !== updateQueue && - (processUpdateQueue( - workInProgress, - updateQueue, - nextProps, - instance, - renderExpirationTime - ), - (oldContext = workInProgress.memoizedState)); + instance.state = oldState; + processUpdateQueue( + workInProgress, + nextProps, + instance, + renderExpirationTime + ); + oldContext = workInProgress.memoizedState; oldProps !== nextProps || oldState !== oldContext || didPerformWorkStackCursor.current || @@ -4159,6 +4065,7 @@ function updateClassComponent( (nextProps = !1)); } else (instance = workInProgress.stateNode), + cloneUpdateQueue(current$$1, workInProgress), (oldProps = workInProgress.memoizedProps), (instance.props = workInProgress.type === workInProgress.elementType @@ -4187,17 +4094,14 @@ function updateClassComponent( )), (hasForceUpdate = !1), (oldContext = workInProgress.memoizedState), - (oldState = instance.state = oldContext), - (updateQueue = workInProgress.updateQueue), - null !== updateQueue && - (processUpdateQueue( - workInProgress, - updateQueue, - nextProps, - instance, - renderExpirationTime - ), - (oldState = workInProgress.memoizedState)), + (instance.state = oldContext), + processUpdateQueue( + workInProgress, + nextProps, + instance, + renderExpirationTime + ), + (oldState = workInProgress.memoizedState), oldProps !== nextProps || oldContext !== oldState || didPerformWorkStackCursor.current || @@ -4517,6 +4421,7 @@ function initSuspenseListRenderState( ? (workInProgress.memoizedState = { isBackwards: isBackwards, rendering: null, + renderingStartTime: 0, last: lastContentRow, tail: tail, tailExpiration: 0, @@ -4525,6 +4430,7 @@ function initSuspenseListRenderState( }) : ((renderState.isBackwards = isBackwards), (renderState.rendering = null), + (renderState.renderingStartTime = 0), (renderState.last = lastContentRow), (renderState.tail = tail), (renderState.tailExpiration = 0), @@ -4852,16 +4758,17 @@ updateHostComponent$1 = function(current, workInProgress, type, newProps) { } }; 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.effectTag |= 4)); + oldText !== newText + ? ((current = requiredContext(rootInstanceStackCursor.current)), + (oldText = requiredContext(contextStackCursor$1.current)), + (workInProgress.stateNode = createTextInstance( + newText, + current, + oldText, + workInProgress + )), + (workInProgress.effectTag |= 4)) + : (workInProgress.stateNode = current.stateNode); }; function cutOffTailIfNeeded(renderState, hasRenderedATailFallback) { switch (renderState.tailMode) { @@ -4891,24 +4798,32 @@ function completeWork(current, workInProgress, renderExpirationTime$jscomp$0) { var newProps = workInProgress.pendingProps; switch (workInProgress.tag) { case 2: - break; case 16: - break; case 15: case 0: - break; + case 11: + case 7: + case 8: + case 12: + case 9: + case 14: + return null; case 1: - isContextProvider(workInProgress.type) && popContext(workInProgress); - break; + return ( + isContextProvider(workInProgress.type) && popContext(workInProgress), + null + ); case 3: - popHostContainer(workInProgress); - popTopLevelContextObject(workInProgress); - current = workInProgress.stateNode; - current.pendingContext && - ((current.context = current.pendingContext), - (current.pendingContext = null)); - updateHostContainer(workInProgress); - break; + return ( + popHostContainer(workInProgress), + popTopLevelContextObject(workInProgress), + (current = workInProgress.stateNode), + current.pendingContext && + ((current.context = current.pendingContext), + (current.pendingContext = null)), + updateHostContainer(workInProgress), + null + ); case 5: popHostContext(workInProgress); var rootContainerInstance = requiredContext( @@ -4925,7 +4840,14 @@ function completeWork(current, workInProgress, renderExpirationTime$jscomp$0) { ), current.ref !== workInProgress.ref && (workInProgress.effectTag |= 128); - else if (newProps) { + 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." + ); + return null; + } requiredContext(contextStackCursor$1.current); current = nextReactTag; nextReactTag += 2; @@ -4955,11 +4877,8 @@ function completeWork(current, workInProgress, renderExpirationTime$jscomp$0) { appendAllChildren(current, workInProgress, !1, !1); workInProgress.stateNode = current; null !== workInProgress.ref && (workInProgress.effectTag |= 128); - } else 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." - ); - break; + } + return null; case 6: if (current && null != workInProgress.stateNode) updateHostText$1( @@ -4982,9 +4901,7 @@ function completeWork(current, workInProgress, renderExpirationTime$jscomp$0) { workInProgress ); } - break; - case 11: - break; + return null; case 13: pop(suspenseStackCursor, workInProgress); newProps = workInProgress.memoizedState; @@ -5032,31 +4949,24 @@ function completeWork(current, workInProgress, renderExpirationTime$jscomp$0) { )); } newProps && (workInProgress.effectTag |= 4); - break; - case 7: - break; - case 8: - break; - case 12: - break; + return null; case 4: - popHostContainer(workInProgress); - updateHostContainer(workInProgress); - break; + return ( + popHostContainer(workInProgress), + updateHostContainer(workInProgress), + null + ); case 10: - popProvider(workInProgress); - break; - case 9: - break; - case 14: - break; + return popProvider(workInProgress), null; case 17: - isContextProvider(workInProgress.type) && popContext(workInProgress); - break; + return ( + isContextProvider(workInProgress.type) && popContext(workInProgress), + null + ); case 19: pop(suspenseStackCursor, workInProgress); newProps = workInProgress.memoizedState; - if (null === newProps) break; + if (null === newProps) return null; rootContainerInstance = 0 !== (workInProgress.effectTag & 64); updatePayload = newProps.rendering; if (null === updatePayload) @@ -5151,13 +5061,15 @@ function completeWork(current, workInProgress, renderExpirationTime$jscomp$0) { null === newProps.tail && "hidden" === newProps.tailMode && !updatePayload.alternate) - ) { - workInProgress = workInProgress.lastEffect = newProps.lastEffect; - null !== workInProgress && (workInProgress.nextEffect = null); - break; - } + ) + return ( + (workInProgress = workInProgress.lastEffect = + newProps.lastEffect), + null !== workInProgress && (workInProgress.nextEffect = null), + null + ); } else - now() > newProps.tailExpiration && + 2 * now() - newProps.renderingStartTime > newProps.tailExpiration && 1 < renderExpirationTime$jscomp$0 && ((workInProgress.effectTag |= 64), (rootContainerInstance = !0), @@ -5176,14 +5088,14 @@ function completeWork(current, workInProgress, renderExpirationTime$jscomp$0) { : (workInProgress.child = updatePayload), (newProps.last = updatePayload)); } - if (null !== newProps.tail) - return ( - 0 === newProps.tailExpiration && + return null !== newProps.tail + ? (0 === newProps.tailExpiration && (newProps.tailExpiration = now() + 500), (current = newProps.tail), (newProps.rendering = current), (newProps.tail = current.sibling), (newProps.lastEffect = workInProgress.lastEffect), + (newProps.renderingStartTime = now()), (current.sibling = null), (newProps = suspenseStackCursor.current), push( @@ -5191,21 +5103,14 @@ function completeWork(current, workInProgress, renderExpirationTime$jscomp$0) { rootContainerInstance ? (newProps & 1) | 2 : newProps & 1, workInProgress ), - current - ); - break; - case 20: - break; - case 21: - break; - default: - throw Error( - "Unknown unit of work tag (" + - workInProgress.tag + - "). This error is likely caused by a bug in React. Please file an issue." - ); + current) + : null; } - 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." + ); } function unwindWork(workInProgress) { switch (workInProgress.tag) { @@ -5322,8 +5227,9 @@ function commitBeforeMutationLifeCycles(current$$1, finishedWork) { case 0: case 11: case 15: + case 22: commitHookEffectList(2, 0, finishedWork); - break; + return; case 1: if (finishedWork.effectTag & 256 && null !== current$$1) { var prevProps = current$$1.memoizedProps, @@ -5337,18 +5243,17 @@ function commitBeforeMutationLifeCycles(current$$1, finishedWork) { ); current$$1.__reactInternalSnapshotBeforeUpdate = finishedWork; } - break; + return; case 3: case 5: case 6: case 4: case 17: - 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." - ); + return; } + throw Error( + "This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue." + ); } function commitHookEffectList(unmountTag, mountTag, finishedWork) { finishedWork = finishedWork.updateQueue; @@ -5367,6 +5272,101 @@ function commitHookEffectList(unmountTag, mountTag, finishedWork) { } while (effect !== finishedWork); } } +function commitLifeCycles( + finishedRoot, + current$$1, + finishedWork, + committedExpirationTime +) { + switch (finishedWork.tag) { + case 0: + case 11: + case 15: + case 22: + commitHookEffectList(16, 32, finishedWork); + return; + case 1: + finishedRoot = finishedWork.stateNode; + if (finishedWork.effectTag & 4) + if (null === current$$1) finishedRoot.componentDidMount(); + else { + var prevProps = + finishedWork.elementType === finishedWork.type + ? current$$1.memoizedProps + : resolveDefaultProps( + finishedWork.type, + current$$1.memoizedProps + ); + finishedRoot.componentDidUpdate( + prevProps, + current$$1.memoizedState, + finishedRoot.__reactInternalSnapshotBeforeUpdate + ); + } + current$$1 = finishedWork.updateQueue; + null !== current$$1 && + commitUpdateQueue( + finishedWork, + current$$1, + finishedRoot, + committedExpirationTime + ); + return; + case 3: + current$$1 = finishedWork.updateQueue; + if (null !== current$$1) { + finishedRoot = null; + if (null !== finishedWork.child) + switch (finishedWork.child.tag) { + case 5: + finishedRoot = finishedWork.child.stateNode.canonical; + break; + case 1: + finishedRoot = finishedWork.child.stateNode; + } + commitUpdateQueue( + finishedWork, + current$$1, + finishedRoot, + committedExpirationTime + ); + } + return; + case 5: + if (null === current$$1 && finishedWork.effectTag & 4) + throw Error( + "The current renderer does not support mutation. This error is likely caused by a bug in React. Please file an issue." + ); + return; + case 6: + return; + case 4: + return; + case 12: + committedExpirationTime = finishedWork.memoizedProps.onRender; + "function" === typeof committedExpirationTime && + committedExpirationTime( + finishedWork.memoizedProps.id, + null === current$$1 ? "mount" : "update", + finishedWork.actualDuration, + finishedWork.treeBaseDuration, + finishedWork.actualStartTime, + commitTime, + finishedRoot.memoizedInteractions + ); + return; + case 13: + return; + case 19: + case 17: + case 20: + case 21: + return; + } + throw Error( + "This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue." + ); +} function commitUnmount(finishedRoot, current$$1$jscomp$0, renderPriorityLevel) { "function" === typeof onCommitFiberUnmount && onCommitFiberUnmount(current$$1$jscomp$0); @@ -5375,13 +5375,14 @@ function commitUnmount(finishedRoot, current$$1$jscomp$0, renderPriorityLevel) { case 11: case 14: case 15: + case 22: finishedRoot = current$$1$jscomp$0.updateQueue; if ( null !== finishedRoot && ((finishedRoot = finishedRoot.lastEffect), null !== finishedRoot) ) { var firstEffect = finishedRoot.next; - runWithPriority$1( + runWithPriority( 97 < renderPriorityLevel ? 97 : renderPriorityLevel, function() { var effect = firstEffect; @@ -5429,6 +5430,7 @@ function detachFiber(current$$1) { current$$1.lastEffect = null; current$$1.pendingProps = null; current$$1.memoizedProps = null; + current$$1.stateNode = null; null !== alternate && detachFiber(alternate); } function commitWork(current$$1, finishedWork) { @@ -5437,6 +5439,7 @@ function commitWork(current$$1, finishedWork) { case 11: case 14: case 15: + case 22: commitHookEffectList(4, 8, finishedWork); return; case 12: @@ -5450,19 +5453,20 @@ function commitWork(current$$1, finishedWork) { attachSuspenseRetryListeners(finishedWork); return; } - a: switch (finishedWork.tag) { - case 1: - case 5: - case 6: - case 20: - break a; - case 3: - case 4: - break a; - 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." - ); + a: { + switch (finishedWork.tag) { + case 1: + case 5: + case 6: + case 20: + break a; + case 3: + case 4: + break a; + } + throw Error( + "This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue." + ); } } function attachSuspenseRetryListeners(finishedWork) { @@ -5936,47 +5940,44 @@ function performConcurrentWorkOnRoot(root, didTimeout) { function performSyncWorkOnRoot(root) { var lastExpiredTime = root.lastExpiredTime; lastExpiredTime = 0 !== lastExpiredTime ? lastExpiredTime : 1073741823; - if (root.finishedExpirationTime === lastExpiredTime) commitRoot(root); - else { - if ((executionContext & (RenderContext | CommitContext)) !== NoContext) - throw Error("Should not already be working."); - flushPassiveEffects(); - if (root !== workInProgressRoot || lastExpiredTime !== renderExpirationTime) + if ((executionContext & (RenderContext | CommitContext)) !== NoContext) + throw Error("Should not already be working."); + flushPassiveEffects(); + if (root !== workInProgressRoot || lastExpiredTime !== renderExpirationTime) + prepareFreshStack(root, lastExpiredTime), + startWorkOnPendingInteractions(root, lastExpiredTime); + if (null !== workInProgress) { + var prevExecutionContext = executionContext; + executionContext |= RenderContext; + var prevDispatcher = pushDispatcher(root), + prevInteractions = pushInteractions(root); + do + try { + workLoopSync(); + break; + } catch (thrownValue) { + handleError(root, thrownValue); + } + while (1); + resetContextDependencies(); + executionContext = prevExecutionContext; + ReactCurrentDispatcher.current = prevDispatcher; + tracing.__interactionsRef.current = prevInteractions; + if (workInProgressRootExitStatus === RootFatalErrored) + throw ((prevExecutionContext = workInProgressRootFatalError), prepareFreshStack(root, lastExpiredTime), - startWorkOnPendingInteractions(root, lastExpiredTime); - if (null !== workInProgress) { - var prevExecutionContext = executionContext; - executionContext |= RenderContext; - var prevDispatcher = pushDispatcher(root), - prevInteractions = pushInteractions(root); - do - try { - workLoopSync(); - break; - } catch (thrownValue) { - handleError(root, thrownValue); - } - while (1); - resetContextDependencies(); - executionContext = prevExecutionContext; - ReactCurrentDispatcher.current = prevDispatcher; - tracing.__interactionsRef.current = prevInteractions; - if (workInProgressRootExitStatus === RootFatalErrored) - throw ((prevExecutionContext = workInProgressRootFatalError), - prepareFreshStack(root, lastExpiredTime), - markRootSuspendedAtTime(root, lastExpiredTime), - ensureRootIsScheduled(root), - prevExecutionContext); - if (null !== workInProgress) - throw Error( - "Cannot commit an incomplete root. This error is likely caused by a bug in React. Please file an issue." - ); - root.finishedWork = root.current.alternate; - root.finishedExpirationTime = lastExpiredTime; - workInProgressRoot = null; - commitRoot(root); - ensureRootIsScheduled(root); - } + markRootSuspendedAtTime(root, lastExpiredTime), + ensureRootIsScheduled(root), + prevExecutionContext); + if (null !== workInProgress) + throw Error( + "Cannot commit an incomplete root. This error is likely caused by a bug in React. Please file an issue." + ); + root.finishedWork = root.current.alternate; + root.finishedExpirationTime = lastExpiredTime; + workInProgressRoot = null; + commitRoot(root); + ensureRootIsScheduled(root); } return null; } @@ -6065,8 +6066,15 @@ function handleError(root$jscomp$0, thrownValue) { "object" === typeof value && "function" === typeof value.then ) { - var thenable = value, - hasInvisibleParentBoundary = + var thenable = value; + if (0 === (sourceFiber.mode & 2)) { + var currentSource = sourceFiber.alternate; + currentSource + ? ((sourceFiber.memoizedState = currentSource.memoizedState), + (sourceFiber.expirationTime = currentSource.expirationTime)) + : (sourceFiber.memoizedState = null); + } + var hasInvisibleParentBoundary = 0 !== (suspenseStackCursor.current & 1), _workInProgress = returnFiber; do { @@ -6346,11 +6354,12 @@ function getRemainingExpirationTime(fiber) { } function commitRoot(root) { var renderPriorityLevel = getCurrentPriorityLevel(); - runWithPriority$1(99, commitRootImpl.bind(null, root, renderPriorityLevel)); + runWithPriority(99, commitRootImpl.bind(null, root, renderPriorityLevel)); return null; } function commitRootImpl(root$jscomp$1, renderPriorityLevel$jscomp$1) { - flushPassiveEffects(); + do flushPassiveEffects(); + while (null !== rootWithPendingPassiveEffects); if ((executionContext & (RenderContext | CommitContext)) !== NoContext) throw Error("Should not already be working."); var finishedWork = root$jscomp$1.finishedWork, @@ -6489,108 +6498,24 @@ function commitRootImpl(root$jscomp$1, renderPriorityLevel$jscomp$1) { ) { var effectTag$jscomp$0 = nextEffect.effectTag; - if (effectTag$jscomp$0 & 36) { - renderPriorityLevel = effectTag; - var current$$1$jscomp$1 = nextEffect.alternate; - currentRef = nextEffect; - root = current$$1; - switch (currentRef.tag) { - case 0: - case 11: - case 15: - commitHookEffectList(16, 32, currentRef); - break; - case 1: - var instance = currentRef.stateNode; - if (currentRef.effectTag & 4) - if (null === current$$1$jscomp$1) - instance.componentDidMount(); - else { - var prevProps = - currentRef.elementType === currentRef.type - ? current$$1$jscomp$1.memoizedProps - : resolveDefaultProps( - currentRef.type, - current$$1$jscomp$1.memoizedProps - ); - instance.componentDidUpdate( - prevProps, - current$$1$jscomp$1.memoizedState, - instance.__reactInternalSnapshotBeforeUpdate - ); - } - var updateQueue = currentRef.updateQueue; - null !== updateQueue && - commitUpdateQueue(currentRef, updateQueue, instance, root); - break; - case 3: - var _updateQueue = currentRef.updateQueue; - if (null !== _updateQueue) { - renderPriorityLevel = null; - if (null !== currentRef.child) - switch (currentRef.child.tag) { - case 5: - renderPriorityLevel = - currentRef.child.stateNode.canonical; - break; - case 1: - renderPriorityLevel = currentRef.child.stateNode; - } - commitUpdateQueue( - currentRef, - _updateQueue, - renderPriorityLevel, - root - ); - } - break; - case 5: - if (null === current$$1$jscomp$1 && currentRef.effectTag & 4) - throw Error( - "The current renderer does not support mutation. This error is likely caused by a bug in React. Please file an issue." - ); - break; - case 6: - break; - case 4: - break; - case 12: - var onRender = currentRef.memoizedProps.onRender; - "function" === typeof onRender && - onRender( - currentRef.memoizedProps.id, - null === current$$1$jscomp$1 ? "mount" : "update", - currentRef.actualDuration, - currentRef.treeBaseDuration, - currentRef.actualStartTime, - commitTime, - renderPriorityLevel.memoizedInteractions - ); - break; - case 13: - break; - case 19: - case 17: - case 20: - case 21: - 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." - ); - } - } + effectTag$jscomp$0 & 36 && + commitLifeCycles( + effectTag, + nextEffect.alternate, + nextEffect, + current$$1 + ); if (effectTag$jscomp$0 & 128) { currentRef = void 0; var ref = nextEffect.ref; if (null !== ref) { - var instance$jscomp$0 = nextEffect.stateNode; + var instance = nextEffect.stateNode; switch (nextEffect.tag) { case 5: - currentRef = instance$jscomp$0.canonical; + currentRef = instance.canonical; break; default: - currentRef = instance$jscomp$0; + currentRef = instance; } "function" === typeof ref ? ref(currentRef) @@ -6630,13 +6555,13 @@ function commitRootImpl(root$jscomp$1, renderPriorityLevel$jscomp$1) { for ( remainingExpirationTimeBeforeCommit = spawnedWorkDuringRender, spawnedWorkDuringRender = null, - current$$1$jscomp$1 = 0; - current$$1$jscomp$1 < remainingExpirationTimeBeforeCommit.length; - current$$1$jscomp$1++ + ref = 0; + ref < remainingExpirationTimeBeforeCommit.length; + ref++ ) scheduleInteractions( root$jscomp$1, - remainingExpirationTimeBeforeCommit[current$$1$jscomp$1], + remainingExpirationTimeBeforeCommit[ref], root$jscomp$1.memoizedInteractions ); schedulePendingInteractions(root$jscomp$1, renderPriorityLevel$jscomp$1); @@ -6682,7 +6607,7 @@ function flushPassiveEffects() { ? 97 : pendingPassiveEffectsRenderPriority; pendingPassiveEffectsRenderPriority = 90; - return runWithPriority$1(priorityLevel, flushPassiveEffectsImpl); + return runWithPriority(priorityLevel, flushPassiveEffectsImpl); } } function flushPassiveEffectsImpl() { @@ -6708,6 +6633,7 @@ function flushPassiveEffectsImpl() { case 0: case 11: case 15: + case 22: commitHookEffectList(128, 0, finishedWork), commitHookEffectList(0, 64, finishedWork); } @@ -6930,6 +6856,7 @@ beginWork$$1 = function(current$$1, workInProgress, renderExpirationTime) { null !== renderState.state && void 0 !== renderState.state ? renderState.state : null; + initializeUpdateQueue(workInProgress); var getDerivedStateFromProps = updateExpirationTime.getDerivedStateFromProps; "function" === typeof getDerivedStateFromProps && @@ -6967,62 +6894,63 @@ beginWork$$1 = function(current$$1, workInProgress, renderExpirationTime) { (workInProgress = workInProgress.child); return workInProgress; case 16: - renderState = workInProgress.elementType; - null !== current$$1 && - ((current$$1.alternate = null), - (workInProgress.alternate = null), - (workInProgress.effectTag |= 2)); - current$$1 = workInProgress.pendingProps; - initializeLazyComponentType(renderState); - if (1 !== renderState._status) throw renderState._result; - renderState = renderState._result; - workInProgress.type = renderState; - hasContext = workInProgress.tag = resolveLazyComponentTag(renderState); - current$$1 = resolveDefaultProps(renderState, current$$1); - switch (hasContext) { - case 0: - workInProgress = updateFunctionComponent( - null, - workInProgress, - renderState, - current$$1, - renderExpirationTime - ); - break; - case 1: - workInProgress = updateClassComponent( - null, - workInProgress, - renderState, - current$$1, - renderExpirationTime - ); - break; - case 11: - workInProgress = updateForwardRef( - null, - workInProgress, - renderState, - current$$1, - renderExpirationTime - ); - break; - case 14: - workInProgress = updateMemoComponent( - null, - workInProgress, - renderState, - resolveDefaultProps(renderState.type, current$$1), - updateExpirationTime, - renderExpirationTime - ); - break; - default: - throw Error( - "Element type is invalid. Received a promise that resolves to: " + - renderState + - ". Lazy element type must resolve to a class or function." - ); + a: { + renderState = workInProgress.elementType; + null !== current$$1 && + ((current$$1.alternate = null), + (workInProgress.alternate = null), + (workInProgress.effectTag |= 2)); + current$$1 = workInProgress.pendingProps; + initializeLazyComponentType(renderState); + if (1 !== renderState._status) throw renderState._result; + renderState = renderState._result; + workInProgress.type = renderState; + hasContext = workInProgress.tag = resolveLazyComponentTag(renderState); + current$$1 = resolveDefaultProps(renderState, current$$1); + switch (hasContext) { + case 0: + workInProgress = updateFunctionComponent( + null, + workInProgress, + renderState, + current$$1, + renderExpirationTime + ); + break a; + case 1: + workInProgress = updateClassComponent( + null, + workInProgress, + renderState, + current$$1, + renderExpirationTime + ); + break a; + case 11: + workInProgress = updateForwardRef( + null, + workInProgress, + renderState, + current$$1, + renderExpirationTime + ); + break a; + case 14: + workInProgress = updateMemoComponent( + null, + workInProgress, + renderState, + resolveDefaultProps(renderState.type, current$$1), + updateExpirationTime, + renderExpirationTime + ); + break a; + } + throw Error( + "Element type is invalid. Received a promise that resolves to: " + + renderState + + ". Lazy element type must resolve to a class or function." + ); } return workInProgress; case 0: @@ -7060,16 +6988,17 @@ beginWork$$1 = function(current$$1, workInProgress, renderExpirationTime) { case 3: pushHostRootContext(workInProgress); updateExpirationTime = workInProgress.updateQueue; - if (null === updateExpirationTime) + if (null === current$$1 || null === updateExpirationTime) throw Error( "If the root does not have an updateQueue, we should have already bailed out. This error is likely caused by a bug in React. Please file an issue." ); + updateExpirationTime = workInProgress.pendingProps; renderState = workInProgress.memoizedState; renderState = null !== renderState ? renderState.element : null; + cloneUpdateQueue(current$$1, workInProgress); processUpdateQueue( workInProgress, updateExpirationTime, - workInProgress.pendingProps, null, renderExpirationTime ); @@ -7648,6 +7577,9 @@ function createFiberFromTypeAndProps( fiberTag = 16; owner = null; break a; + case REACT_CHUNK_TYPE: + fiberTag = 22; + break a; } throw Error( "Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: " + @@ -7826,7 +7758,11 @@ function createPortal(children, containerInfo, implementation) { implementation: implementation }; } -var fabricDispatchCommand = nativeFabricUIManager.dispatchCommand; +function _inheritsLoose(subClass, superClass) { + subClass.prototype = Object.create(superClass.prototype); + subClass.prototype.constructor = subClass; + subClass.__proto__ = superClass; +} function findNodeHandle(componentOrHandle) { if (null == componentOrHandle) return null; if ("number" === typeof componentOrHandle) return componentOrHandle; @@ -7967,12 +7903,17 @@ var roots = new Map(), findNodeHandle: findNodeHandle, dispatchCommand: function(handle, command, args) { null != handle._nativeTag && - null != handle._internalInstanceHandle && - fabricDispatchCommand( - handle._internalInstanceHandle.stateNode.node, - command, - args - ); + (handle._internalInstanceHandle + ? nativeFabricUIManager.dispatchCommand( + handle._internalInstanceHandle.stateNode.node, + command, + args + ) + : ReactNativePrivateInterface.UIManager.dispatchViewManagerCommand( + handle._nativeTag, + command, + args + )); }, render: function(element, containerTag, callback) { var root = roots.get(containerTag); @@ -7983,6 +7924,7 @@ var roots = new Map(), uninitializedFiber = createFiber(3, null, null, uninitializedFiber); root.current = uninitializedFiber; uninitializedFiber.stateNode = root; + initializeUpdateQueue(uninitializedFiber); roots.set(containerTag, root); } updateContainer(element, root, null, callback); @@ -8132,7 +8074,7 @@ var roots = new Map(), throw Error("getInspectorDataForViewTag() is not available in production"); }, bundleType: 0, - version: "16.11.0", + version: "16.12.0-experimental-19f6fe170", rendererPackageName: "react-native-renderer" }); var ReactFabric$2 = { default: ReactFabric }, diff --git a/Libraries/Renderer/implementations/ReactFabric-profiling.js b/Libraries/Renderer/implementations/ReactFabric-profiling.js index d36acbd2303fcf..cf5e8cc3c3b89f 100644 --- a/Libraries/Renderer/implementations/ReactFabric-profiling.js +++ b/Libraries/Renderer/implementations/ReactFabric-profiling.js @@ -504,53 +504,27 @@ function recordTouchStart(touch) { } function recordTouchMove(touch) { var touchRecord = touchBank[getTouchIdentifier(touch)]; - touchRecord - ? ((touchRecord.touchActive = !0), - (touchRecord.previousPageX = touchRecord.currentPageX), - (touchRecord.previousPageY = touchRecord.currentPageY), - (touchRecord.previousTimeStamp = touchRecord.currentTimeStamp), - (touchRecord.currentPageX = touch.pageX), - (touchRecord.currentPageY = touch.pageY), - (touchRecord.currentTimeStamp = timestampForTouch(touch)), - (touchHistory.mostRecentTimeStamp = timestampForTouch(touch))) - : console.warn( - "Cannot record touch move without a touch start.\nTouch Move: %s\n", - "Touch Bank: %s", - printTouch(touch), - printTouchBank() - ); + touchRecord && + ((touchRecord.touchActive = !0), + (touchRecord.previousPageX = touchRecord.currentPageX), + (touchRecord.previousPageY = touchRecord.currentPageY), + (touchRecord.previousTimeStamp = touchRecord.currentTimeStamp), + (touchRecord.currentPageX = touch.pageX), + (touchRecord.currentPageY = touch.pageY), + (touchRecord.currentTimeStamp = timestampForTouch(touch)), + (touchHistory.mostRecentTimeStamp = timestampForTouch(touch))); } function recordTouchEnd(touch) { var touchRecord = touchBank[getTouchIdentifier(touch)]; - touchRecord - ? ((touchRecord.touchActive = !1), - (touchRecord.previousPageX = touchRecord.currentPageX), - (touchRecord.previousPageY = touchRecord.currentPageY), - (touchRecord.previousTimeStamp = touchRecord.currentTimeStamp), - (touchRecord.currentPageX = touch.pageX), - (touchRecord.currentPageY = touch.pageY), - (touchRecord.currentTimeStamp = timestampForTouch(touch)), - (touchHistory.mostRecentTimeStamp = timestampForTouch(touch))) - : console.warn( - "Cannot record touch end without a touch start.\nTouch End: %s\n", - "Touch Bank: %s", - printTouch(touch), - printTouchBank() - ); -} -function printTouch(touch) { - return JSON.stringify({ - identifier: touch.identifier, - pageX: touch.pageX, - pageY: touch.pageY, - timestamp: timestampForTouch(touch) - }); -} -function printTouchBank() { - var printed = JSON.stringify(touchBank.slice(0, 20)); - 20 < touchBank.length && - (printed += " (original size: " + touchBank.length + ")"); - return printed; + touchRecord && + ((touchRecord.touchActive = !1), + (touchRecord.previousPageX = touchRecord.currentPageX), + (touchRecord.previousPageY = touchRecord.currentPageY), + (touchRecord.previousTimeStamp = touchRecord.currentTimeStamp), + (touchRecord.currentPageX = touch.pageX), + (touchRecord.currentPageY = touch.pageY), + (touchRecord.currentTimeStamp = timestampForTouch(touch)), + (touchHistory.mostRecentTimeStamp = timestampForTouch(touch))); } var ResponderTouchHistoryStore = { recordTouchTrack: function(topLevelType, nativeEvent) { @@ -683,13 +657,7 @@ var eventTypes = { "topTouchCancel" === topLevelType ) if (0 <= trackedTouchCount) --trackedTouchCount; - else - return ( - console.warn( - "Ended a touch event which was not counted in `trackedTouchCount`." - ), - null - ); + else return null; ResponderTouchHistoryStore.recordTouchTrack(topLevelType, nativeEvent); if ( targetInst && @@ -1036,7 +1004,8 @@ var hasSymbol = "function" === typeof Symbol && Symbol.for, ? Symbol.for("react.suspense_list") : 60120, REACT_MEMO_TYPE = hasSymbol ? Symbol.for("react.memo") : 60115, - REACT_LAZY_TYPE = hasSymbol ? Symbol.for("react.lazy") : 60116; + REACT_LAZY_TYPE = hasSymbol ? Symbol.for("react.lazy") : 60116, + REACT_CHUNK_TYPE = hasSymbol ? Symbol.for("react.chunk") : 60121; hasSymbol && Symbol.for("react.fundamental"); hasSymbol && Symbol.for("react.responder"); hasSymbol && Symbol.for("react.scope"); @@ -1101,6 +1070,8 @@ function getComponentName(type) { ); case REACT_MEMO_TYPE: return getComponentName(type.type); + case REACT_CHUNK_TYPE: + return getComponentName(type.render); case REACT_LAZY_TYPE: if ((type = 1 === type._status ? type._result : null)) return getComponentName(type); @@ -1488,26 +1459,6 @@ function batchedUpdates(fn, bookkeeping) { restoreStateOfTarget(fn[bookkeeping]); } } -function _inheritsLoose(subClass, superClass) { - subClass.prototype = Object.create(superClass.prototype); - subClass.prototype.constructor = subClass; - subClass.__proto__ = superClass; -} -(function(_React$Component) { - function ReactNativeComponent() { - return _React$Component.apply(this, arguments) || this; - } - _inheritsLoose(ReactNativeComponent, _React$Component); - var _proto = ReactNativeComponent.prototype; - _proto.blur = function() {}; - _proto.focus = function() {}; - _proto.measure = function() {}; - _proto.measureInWindow = function() {}; - _proto.measureLayout = function() {}; - _proto.setNativeProps = function() {}; - return ReactNativeComponent; -})(React.Component); -new Map(); function dispatchEvent(target, topLevelType, nativeEvent) { var eventTarget = null; eventTarget = nativeEvent.target; @@ -1548,21 +1499,21 @@ function shim$1() { "The current renderer does not support hydration. This error is likely caused by a bug in React. Please file an issue." ); } -var _nativeFabricUIManage$1 = nativeFabricUIManager, - createNode = _nativeFabricUIManage$1.createNode, - cloneNode = _nativeFabricUIManage$1.cloneNode, - cloneNodeWithNewChildren = _nativeFabricUIManage$1.cloneNodeWithNewChildren, +var _nativeFabricUIManage = nativeFabricUIManager, + createNode = _nativeFabricUIManage.createNode, + cloneNode = _nativeFabricUIManage.cloneNode, + cloneNodeWithNewChildren = _nativeFabricUIManage.cloneNodeWithNewChildren, cloneNodeWithNewChildrenAndProps = - _nativeFabricUIManage$1.cloneNodeWithNewChildrenAndProps, - cloneNodeWithNewProps = _nativeFabricUIManage$1.cloneNodeWithNewProps, - createChildNodeSet = _nativeFabricUIManage$1.createChildSet, - appendChildNode = _nativeFabricUIManage$1.appendChild, - appendChildNodeToSet = _nativeFabricUIManage$1.appendChildToSet, - completeRoot = _nativeFabricUIManage$1.completeRoot, - registerEventHandler = _nativeFabricUIManage$1.registerEventHandler, - fabricMeasure = _nativeFabricUIManage$1.measure, - fabricMeasureInWindow = _nativeFabricUIManage$1.measureInWindow, - fabricMeasureLayout = _nativeFabricUIManage$1.measureLayout, + _nativeFabricUIManage.cloneNodeWithNewChildrenAndProps, + cloneNodeWithNewProps = _nativeFabricUIManage.cloneNodeWithNewProps, + createChildNodeSet = _nativeFabricUIManage.createChildSet, + appendChildNode = _nativeFabricUIManage.appendChild, + appendChildNodeToSet = _nativeFabricUIManage.appendChildToSet, + completeRoot = _nativeFabricUIManage.completeRoot, + registerEventHandler = _nativeFabricUIManage.registerEventHandler, + fabricMeasure = _nativeFabricUIManage.measure, + fabricMeasureInWindow = _nativeFabricUIManage.measureInWindow, + fabricMeasureLayout = _nativeFabricUIManage.measureLayout, getViewConfigForType = ReactNativePrivateInterface.ReactNativeViewConfigRegistry.get, nextReactTag = 2; @@ -1846,7 +1797,7 @@ function reactPriorityToSchedulerPriority(reactPriorityLevel) { throw Error("Unknown priority level."); } } -function runWithPriority$1(reactPriorityLevel, fn) { +function runWithPriority(reactPriorityLevel, fn) { reactPriorityLevel = reactPriorityToSchedulerPriority(reactPriorityLevel); return Scheduler_runWithPriority(reactPriorityLevel, fn); } @@ -1878,7 +1829,7 @@ function flushSyncCallbackQueueImpl() { var i = 0; try { var queue = syncQueue; - runWithPriority$1(99, function() { + runWithPriority(99, function() { for (; i < queue.length; i++) { var callback = queue[i]; do callback = callback(!0); @@ -2015,237 +1966,195 @@ function readContext(context, observedBits) { return context._currentValue2; } var hasForceUpdate = !1; -function createUpdateQueue(baseState) { - return { - baseState: baseState, - firstUpdate: null, - lastUpdate: null, - firstCapturedUpdate: null, - lastCapturedUpdate: null, - firstEffect: null, - lastEffect: null, - firstCapturedEffect: null, - lastCapturedEffect: null +function initializeUpdateQueue(fiber) { + fiber.updateQueue = { + baseState: fiber.memoizedState, + baseQueue: null, + shared: { pending: null }, + effects: null }; } -function cloneUpdateQueue(currentQueue) { - return { - baseState: currentQueue.baseState, - firstUpdate: currentQueue.firstUpdate, - lastUpdate: currentQueue.lastUpdate, - firstCapturedUpdate: null, - lastCapturedUpdate: null, - firstEffect: null, - lastEffect: null, - firstCapturedEffect: null, - lastCapturedEffect: null - }; +function cloneUpdateQueue(current, workInProgress) { + current = current.updateQueue; + workInProgress.updateQueue === current && + (workInProgress.updateQueue = { + baseState: current.baseState, + baseQueue: current.baseQueue, + shared: current.shared, + effects: current.effects + }); } function createUpdate(expirationTime, suspenseConfig) { - return { + expirationTime = { expirationTime: expirationTime, suspenseConfig: suspenseConfig, tag: 0, payload: null, callback: null, - next: null, - nextEffect: null + next: null }; -} -function appendUpdateToQueue(queue, update) { - null === queue.lastUpdate - ? (queue.firstUpdate = queue.lastUpdate = update) - : ((queue.lastUpdate.next = update), (queue.lastUpdate = update)); + return (expirationTime.next = expirationTime); } function enqueueUpdate(fiber, update) { - var alternate = fiber.alternate; - if (null === alternate) { - var queue1 = fiber.updateQueue; - var queue2 = null; - null === queue1 && - (queue1 = fiber.updateQueue = createUpdateQueue(fiber.memoizedState)); - } else - (queue1 = fiber.updateQueue), - (queue2 = alternate.updateQueue), - null === queue1 - ? null === queue2 - ? ((queue1 = fiber.updateQueue = createUpdateQueue( - fiber.memoizedState - )), - (queue2 = alternate.updateQueue = createUpdateQueue( - alternate.memoizedState - ))) - : (queue1 = fiber.updateQueue = cloneUpdateQueue(queue2)) - : null === queue2 && - (queue2 = alternate.updateQueue = cloneUpdateQueue(queue1)); - null === queue2 || queue1 === queue2 - ? appendUpdateToQueue(queue1, update) - : null === queue1.lastUpdate || null === queue2.lastUpdate - ? (appendUpdateToQueue(queue1, update), - appendUpdateToQueue(queue2, update)) - : (appendUpdateToQueue(queue1, update), (queue2.lastUpdate = update)); + fiber = fiber.updateQueue; + if (null !== fiber) { + fiber = fiber.shared; + var pending = fiber.pending; + null === pending + ? (update.next = update) + : ((update.next = pending.next), (pending.next = update)); + fiber.pending = update; + } } function enqueueCapturedUpdate(workInProgress, update) { - var workInProgressQueue = workInProgress.updateQueue; - workInProgressQueue = - null === workInProgressQueue - ? (workInProgress.updateQueue = createUpdateQueue( - workInProgress.memoizedState - )) - : ensureWorkInProgressQueueIsAClone(workInProgress, workInProgressQueue); - null === workInProgressQueue.lastCapturedUpdate - ? (workInProgressQueue.firstCapturedUpdate = workInProgressQueue.lastCapturedUpdate = update) - : ((workInProgressQueue.lastCapturedUpdate.next = update), - (workInProgressQueue.lastCapturedUpdate = update)); -} -function ensureWorkInProgressQueueIsAClone(workInProgress, queue) { var current = workInProgress.alternate; - null !== current && - queue === current.updateQueue && - (queue = workInProgress.updateQueue = cloneUpdateQueue(queue)); - return queue; -} -function getStateFromUpdate( - workInProgress, - queue, - update, - prevState, - nextProps, - instance -) { - switch (update.tag) { - case 1: - return ( - (workInProgress = update.payload), - "function" === typeof workInProgress - ? workInProgress.call(instance, prevState, nextProps) - : workInProgress - ); - case 3: - workInProgress.effectTag = (workInProgress.effectTag & -4097) | 64; - case 0: - workInProgress = update.payload; - nextProps = - "function" === typeof workInProgress - ? workInProgress.call(instance, prevState, nextProps) - : workInProgress; - if (null === nextProps || void 0 === nextProps) break; - return Object.assign({}, prevState, nextProps); - case 2: - hasForceUpdate = !0; - } - return prevState; + null !== current && cloneUpdateQueue(current, workInProgress); + workInProgress = workInProgress.updateQueue; + current = workInProgress.baseQueue; + null === current + ? ((workInProgress.baseQueue = update.next = update), + (update.next = update)) + : ((update.next = current.next), (current.next = update)); } function processUpdateQueue( - workInProgress, - queue, + workInProgress$jscomp$0, props, instance, renderExpirationTime ) { + var queue = workInProgress$jscomp$0.updateQueue; hasForceUpdate = !1; - queue = ensureWorkInProgressQueueIsAClone(workInProgress, queue); - for ( - var newBaseState = queue.baseState, - newFirstUpdate = null, - newExpirationTime = 0, - update = queue.firstUpdate, - resultState = newBaseState; - null !== update; - - ) { - var updateExpirationTime = update.expirationTime; - updateExpirationTime < renderExpirationTime - ? (null === newFirstUpdate && - ((newFirstUpdate = update), (newBaseState = resultState)), - newExpirationTime < updateExpirationTime && - (newExpirationTime = updateExpirationTime)) - : (markRenderEventTimeAndConfig( - updateExpirationTime, - update.suspenseConfig - ), - (resultState = getStateFromUpdate( - workInProgress, - queue, - update, - resultState, - props, - instance - )), - null !== update.callback && - ((workInProgress.effectTag |= 32), - (update.nextEffect = null), - null === queue.lastEffect - ? (queue.firstEffect = queue.lastEffect = update) - : ((queue.lastEffect.nextEffect = update), - (queue.lastEffect = update)))); - update = update.next; + var baseQueue = queue.baseQueue, + pendingQueue = queue.shared.pending; + if (null !== pendingQueue) { + if (null !== baseQueue) { + var baseFirst = baseQueue.next; + baseQueue.next = pendingQueue.next; + pendingQueue.next = baseFirst; + } + baseQueue = pendingQueue; + queue.shared.pending = null; + baseFirst = workInProgress$jscomp$0.alternate; + null !== baseFirst && + ((baseFirst = baseFirst.updateQueue), + null !== baseFirst && (baseFirst.baseQueue = pendingQueue)); } - updateExpirationTime = null; - for (update = queue.firstCapturedUpdate; null !== update; ) { - var _updateExpirationTime = update.expirationTime; - _updateExpirationTime < renderExpirationTime - ? (null === updateExpirationTime && - ((updateExpirationTime = update), - null === newFirstUpdate && (newBaseState = resultState)), - newExpirationTime < _updateExpirationTime && - (newExpirationTime = _updateExpirationTime)) - : ((resultState = getStateFromUpdate( - workInProgress, - queue, - update, - resultState, - props, - instance - )), - null !== update.callback && - ((workInProgress.effectTag |= 32), - (update.nextEffect = null), - null === queue.lastCapturedEffect - ? (queue.firstCapturedEffect = queue.lastCapturedEffect = update) - : ((queue.lastCapturedEffect.nextEffect = update), - (queue.lastCapturedEffect = update)))); - update = update.next; + if (null !== baseQueue) { + baseFirst = baseQueue.next; + var newState = queue.baseState, + newExpirationTime = 0, + newBaseState = null, + newBaseQueueFirst = null, + newBaseQueueLast = null; + if (null !== baseFirst) { + var update = baseFirst; + do { + pendingQueue = update.expirationTime; + if (pendingQueue < renderExpirationTime) { + var clone = { + expirationTime: update.expirationTime, + suspenseConfig: update.suspenseConfig, + tag: update.tag, + payload: update.payload, + callback: update.callback, + next: null + }; + null === newBaseQueueLast + ? ((newBaseQueueFirst = newBaseQueueLast = clone), + (newBaseState = newState)) + : (newBaseQueueLast = newBaseQueueLast.next = clone); + pendingQueue > newExpirationTime && + (newExpirationTime = pendingQueue); + } else { + null !== newBaseQueueLast && + (newBaseQueueLast = newBaseQueueLast.next = { + expirationTime: 1073741823, + suspenseConfig: update.suspenseConfig, + tag: update.tag, + payload: update.payload, + callback: update.callback, + next: null + }); + markRenderEventTimeAndConfig(pendingQueue, update.suspenseConfig); + a: { + var workInProgress = workInProgress$jscomp$0, + update$jscomp$0 = update; + pendingQueue = props; + clone = instance; + switch (update$jscomp$0.tag) { + case 1: + workInProgress = update$jscomp$0.payload; + if ("function" === typeof workInProgress) { + newState = workInProgress.call(clone, newState, pendingQueue); + break a; + } + newState = workInProgress; + break a; + case 3: + workInProgress.effectTag = + (workInProgress.effectTag & -4097) | 64; + case 0: + workInProgress = update$jscomp$0.payload; + pendingQueue = + "function" === typeof workInProgress + ? workInProgress.call(clone, newState, pendingQueue) + : workInProgress; + if (null === pendingQueue || void 0 === pendingQueue) break a; + newState = Object.assign({}, newState, pendingQueue); + break a; + case 2: + hasForceUpdate = !0; + } + } + null !== update.callback && + ((workInProgress$jscomp$0.effectTag |= 32), + (pendingQueue = queue.effects), + null === pendingQueue + ? (queue.effects = [update]) + : pendingQueue.push(update)); + } + update = update.next; + if (null === update || update === baseFirst) + if (((pendingQueue = queue.shared.pending), null === pendingQueue)) + break; + else + (update = baseQueue.next = pendingQueue.next), + (pendingQueue.next = baseFirst), + (queue.baseQueue = baseQueue = pendingQueue), + (queue.shared.pending = null); + } while (1); + } + null === newBaseQueueLast + ? (newBaseState = newState) + : (newBaseQueueLast.next = newBaseQueueFirst); + queue.baseState = newBaseState; + queue.baseQueue = newBaseQueueLast; + markUnprocessedUpdateTime(newExpirationTime); + workInProgress$jscomp$0.expirationTime = newExpirationTime; + workInProgress$jscomp$0.memoizedState = newState; } - null === newFirstUpdate && (queue.lastUpdate = null); - null === updateExpirationTime - ? (queue.lastCapturedUpdate = null) - : (workInProgress.effectTag |= 32); - null === newFirstUpdate && - null === updateExpirationTime && - (newBaseState = resultState); - queue.baseState = newBaseState; - queue.firstUpdate = newFirstUpdate; - queue.firstCapturedUpdate = updateExpirationTime; - markUnprocessedUpdateTime(newExpirationTime); - workInProgress.expirationTime = newExpirationTime; - workInProgress.memoizedState = resultState; } function commitUpdateQueue(finishedWork, finishedQueue, instance) { - null !== finishedQueue.firstCapturedUpdate && - (null !== finishedQueue.lastUpdate && - ((finishedQueue.lastUpdate.next = finishedQueue.firstCapturedUpdate), - (finishedQueue.lastUpdate = finishedQueue.lastCapturedUpdate)), - (finishedQueue.firstCapturedUpdate = finishedQueue.lastCapturedUpdate = null)); - commitUpdateEffects(finishedQueue.firstEffect, instance); - finishedQueue.firstEffect = finishedQueue.lastEffect = null; - commitUpdateEffects(finishedQueue.firstCapturedEffect, instance); - finishedQueue.firstCapturedEffect = finishedQueue.lastCapturedEffect = null; -} -function commitUpdateEffects(effect, instance) { - for (; null !== effect; ) { - var callback = effect.callback; - if (null !== callback) { - effect.callback = null; - if ("function" !== typeof callback) - throw Error( - "Invalid argument passed as callback. Expected a function. Instead received: " + - callback - ); - callback.call(instance); + finishedWork = finishedQueue.effects; + finishedQueue.effects = null; + if (null !== finishedWork) + for ( + finishedQueue = 0; + finishedQueue < finishedWork.length; + finishedQueue++ + ) { + var effect = finishedWork[finishedQueue], + callback = effect.callback; + if (null !== callback) { + effect.callback = null; + if ("function" !== typeof callback) + throw Error( + "Invalid argument passed as callback. Expected a function. Instead received: " + + callback + ); + callback.call(instance); + } } - effect = effect.nextEffect; - } } var ReactCurrentBatchConfig = ReactSharedInternals.ReactCurrentBatchConfig, emptyRefsObject = new React.Component().refs; @@ -2262,10 +2171,8 @@ function applyDerivedStateFromProps( ? ctor : Object.assign({}, ctor, getDerivedStateFromProps); workInProgress.memoizedState = getDerivedStateFromProps; - nextProps = workInProgress.updateQueue; - null !== nextProps && - 0 === workInProgress.expirationTime && - (nextProps.baseState = getDerivedStateFromProps); + 0 === workInProgress.expirationTime && + (workInProgress.updateQueue.baseState = getDerivedStateFromProps); } var classComponentUpdater = { isMounted: function(component) { @@ -2380,6 +2287,7 @@ function mountClassInstance( instance.props = newProps; instance.state = workInProgress.memoizedState; instance.refs = emptyRefsObject; + initializeUpdateQueue(workInProgress); var contextType = ctor.contextType; "object" === typeof contextType && null !== contextType ? (instance.context = readContext(contextType)) @@ -2387,16 +2295,8 @@ function mountClassInstance( ? previousContext : contextStackCursor.current), (instance.context = getMaskedContext(workInProgress, contextType))); - contextType = workInProgress.updateQueue; - null !== contextType && - (processUpdateQueue( - workInProgress, - contextType, - newProps, - instance, - renderExpirationTime - ), - (instance.state = workInProgress.memoizedState)); + processUpdateQueue(workInProgress, newProps, instance, renderExpirationTime); + instance.state = workInProgress.memoizedState; contextType = ctor.getDerivedStateFromProps; "function" === typeof contextType && (applyDerivedStateFromProps(workInProgress, ctor, contextType, newProps), @@ -2412,16 +2312,13 @@ function mountClassInstance( instance.UNSAFE_componentWillMount(), ctor !== instance.state && classComponentUpdater.enqueueReplaceState(instance, instance.state, null), - (contextType = workInProgress.updateQueue), - null !== contextType && - (processUpdateQueue( - workInProgress, - contextType, - newProps, - instance, - renderExpirationTime - ), - (instance.state = workInProgress.memoizedState))); + processUpdateQueue( + workInProgress, + newProps, + instance, + renderExpirationTime + ), + (instance.state = workInProgress.memoizedState)); "function" === typeof instance.componentDidMount && (workInProgress.effectTag |= 4); } @@ -2983,39 +2880,50 @@ function ChildReconciler(shouldTrackSideEffects) { null !== isUnkeyedTopLevelFragment; ) { - if (isUnkeyedTopLevelFragment.key === isObject) - if ( - 7 === isUnkeyedTopLevelFragment.tag - ? newChild.type === REACT_FRAGMENT_TYPE - : isUnkeyedTopLevelFragment.elementType === newChild.type - ) { - deleteRemainingChildren( - returnFiber, - isUnkeyedTopLevelFragment.sibling - ); - currentFirstChild = useFiber( - isUnkeyedTopLevelFragment, - newChild.type === REACT_FRAGMENT_TYPE - ? newChild.props.children - : newChild.props, - expirationTime - ); - currentFirstChild.ref = coerceRef( - returnFiber, - isUnkeyedTopLevelFragment, - newChild - ); - currentFirstChild.return = returnFiber; - returnFiber = currentFirstChild; - break a; - } else { - deleteRemainingChildren( - returnFiber, - isUnkeyedTopLevelFragment - ); - break; + if (isUnkeyedTopLevelFragment.key === isObject) { + switch (isUnkeyedTopLevelFragment.tag) { + case 7: + if (newChild.type === REACT_FRAGMENT_TYPE) { + deleteRemainingChildren( + returnFiber, + isUnkeyedTopLevelFragment.sibling + ); + currentFirstChild = useFiber( + isUnkeyedTopLevelFragment, + newChild.props.children, + expirationTime + ); + currentFirstChild.return = returnFiber; + returnFiber = currentFirstChild; + break a; + } + break; + default: + if ( + isUnkeyedTopLevelFragment.elementType === newChild.type + ) { + deleteRemainingChildren( + returnFiber, + isUnkeyedTopLevelFragment.sibling + ); + currentFirstChild = useFiber( + isUnkeyedTopLevelFragment, + newChild.props, + expirationTime + ); + currentFirstChild.ref = coerceRef( + returnFiber, + isUnkeyedTopLevelFragment, + newChild + ); + currentFirstChild.return = returnFiber; + returnFiber = currentFirstChild; + break a; + } } - else deleteChild(returnFiber, isUnkeyedTopLevelFragment); + deleteRemainingChildren(returnFiber, isUnkeyedTopLevelFragment); + break; + } else deleteChild(returnFiber, isUnkeyedTopLevelFragment); isUnkeyedTopLevelFragment = isUnkeyedTopLevelFragment.sibling; } newChild.type === REACT_FRAGMENT_TYPE @@ -3213,7 +3121,7 @@ function findFirstSuspended(row) { } return null; } -function createResponderListener(responder, props) { +function createDeprecatedResponderListener(responder, props) { return { responder: responder, props: props }; } var ReactCurrentDispatcher$1 = ReactSharedInternals.ReactCurrentDispatcher, @@ -3221,13 +3129,7 @@ var ReactCurrentDispatcher$1 = ReactSharedInternals.ReactCurrentDispatcher, renderExpirationTime$1 = 0, currentlyRenderingFiber$1 = null, currentHook = null, - nextCurrentHook = null, - firstWorkInProgressHook = null, workInProgressHook = null, - nextWorkInProgressHook = null, - remainingExpirationTime = 0, - componentUpdateQueue = null, - sideEffectTag = 0, didScheduleRenderPhaseUpdate = !1, renderPhaseUpdates = null, numberOfReRenders = 0; @@ -3247,53 +3149,45 @@ function renderWithHooks( workInProgress, Component, props, - refOrContext, + secondArg, nextRenderExpirationTime ) { renderExpirationTime$1 = nextRenderExpirationTime; currentlyRenderingFiber$1 = workInProgress; - nextCurrentHook = null !== current ? current.memoizedState : null; + workInProgress.memoizedState = null; + workInProgress.updateQueue = null; + workInProgress.expirationTime = 0; ReactCurrentDispatcher$1.current = - null === nextCurrentHook ? HooksDispatcherOnMount : HooksDispatcherOnUpdate; - workInProgress = Component(props, refOrContext); + null === current || null === current.memoizedState + ? HooksDispatcherOnMount + : HooksDispatcherOnUpdate; + current = Component(props, secondArg); if (didScheduleRenderPhaseUpdate) { do (didScheduleRenderPhaseUpdate = !1), (numberOfReRenders += 1), - (nextCurrentHook = null !== current ? current.memoizedState : null), - (nextWorkInProgressHook = firstWorkInProgressHook), - (componentUpdateQueue = workInProgressHook = currentHook = null), + (workInProgressHook = currentHook = null), + (workInProgress.updateQueue = null), (ReactCurrentDispatcher$1.current = HooksDispatcherOnUpdate), - (workInProgress = Component(props, refOrContext)); + (current = Component(props, secondArg)); while (didScheduleRenderPhaseUpdate); renderPhaseUpdates = null; numberOfReRenders = 0; } ReactCurrentDispatcher$1.current = ContextOnlyDispatcher; - current = currentlyRenderingFiber$1; - current.memoizedState = firstWorkInProgressHook; - current.expirationTime = remainingExpirationTime; - current.updateQueue = componentUpdateQueue; - current.effectTag |= sideEffectTag; - current = null !== currentHook && null !== currentHook.next; + workInProgress = null !== currentHook && null !== currentHook.next; renderExpirationTime$1 = 0; - nextWorkInProgressHook = workInProgressHook = firstWorkInProgressHook = nextCurrentHook = currentHook = currentlyRenderingFiber$1 = null; - remainingExpirationTime = 0; - componentUpdateQueue = null; - sideEffectTag = 0; - if (current) + workInProgressHook = currentHook = currentlyRenderingFiber$1 = null; + if (workInProgress) throw Error( "Rendered fewer hooks than expected. This may be caused by an accidental early return statement." ); - return workInProgress; + return current; } function resetHooks() { ReactCurrentDispatcher$1.current = ContextOnlyDispatcher; renderExpirationTime$1 = 0; - nextWorkInProgressHook = workInProgressHook = firstWorkInProgressHook = nextCurrentHook = currentHook = currentlyRenderingFiber$1 = null; - remainingExpirationTime = 0; - componentUpdateQueue = null; - sideEffectTag = 0; + workInProgressHook = currentHook = currentlyRenderingFiber$1 = null; didScheduleRenderPhaseUpdate = !1; renderPhaseUpdates = null; numberOfReRenders = 0; @@ -3302,37 +3196,42 @@ function mountWorkInProgressHook() { var hook = { memoizedState: null, baseState: null, + baseQueue: null, queue: null, - baseUpdate: null, next: null }; null === workInProgressHook - ? (firstWorkInProgressHook = workInProgressHook = hook) + ? (currentlyRenderingFiber$1.memoizedState = workInProgressHook = hook) : (workInProgressHook = workInProgressHook.next = hook); return workInProgressHook; } function updateWorkInProgressHook() { + if (null === currentHook) { + var nextCurrentHook = currentlyRenderingFiber$1.alternate; + nextCurrentHook = + null !== nextCurrentHook ? nextCurrentHook.memoizedState : null; + } else nextCurrentHook = currentHook.next; + var nextWorkInProgressHook = + null === workInProgressHook + ? currentlyRenderingFiber$1.memoizedState + : workInProgressHook.next; if (null !== nextWorkInProgressHook) (workInProgressHook = nextWorkInProgressHook), - (nextWorkInProgressHook = workInProgressHook.next), - (currentHook = nextCurrentHook), - (nextCurrentHook = null !== currentHook ? currentHook.next : null); + (currentHook = nextCurrentHook); else { if (null === nextCurrentHook) throw Error("Rendered more hooks than during the previous render."); currentHook = nextCurrentHook; - var newHook = { + nextCurrentHook = { memoizedState: currentHook.memoizedState, baseState: currentHook.baseState, + baseQueue: currentHook.baseQueue, queue: currentHook.queue, - baseUpdate: currentHook.baseUpdate, next: null }; - workInProgressHook = - null === workInProgressHook - ? (firstWorkInProgressHook = newHook) - : (workInProgressHook.next = newHook); - nextCurrentHook = currentHook.next; + null === workInProgressHook + ? (currentlyRenderingFiber$1.memoizedState = workInProgressHook = nextCurrentHook) + : (workInProgressHook = workInProgressHook.next = nextCurrentHook); } return workInProgressHook; } @@ -3360,51 +3259,75 @@ function updateReducer(reducer) { while (null !== firstRenderPhaseUpdate); is$1(newState, hook.memoizedState) || (didReceiveUpdate = !0); hook.memoizedState = newState; - hook.baseUpdate === queue.last && (hook.baseState = newState); + null === hook.baseQueue && (hook.baseState = newState); queue.lastRenderedState = newState; return [newState, _dispatch]; } } return [hook.memoizedState, _dispatch]; } - _dispatch = queue.last; - var baseUpdate = hook.baseUpdate; - newState = hook.baseState; - null !== baseUpdate - ? (null !== _dispatch && (_dispatch.next = null), - (_dispatch = baseUpdate.next)) - : (_dispatch = null !== _dispatch ? _dispatch.next : null); + newState = currentHook; + _dispatch = newState.baseQueue; + firstRenderPhaseUpdate = queue.pending; + if (null !== firstRenderPhaseUpdate) { + if (null !== _dispatch) { + var baseFirst = _dispatch.next; + _dispatch.next = firstRenderPhaseUpdate.next; + firstRenderPhaseUpdate.next = baseFirst; + } + newState.baseQueue = _dispatch = firstRenderPhaseUpdate; + queue.pending = null; + } if (null !== _dispatch) { - var newBaseUpdate = (firstRenderPhaseUpdate = null), - _update = _dispatch, - didSkip = !1; + _dispatch = _dispatch.next; + newState = newState.baseState; + var newBaseQueueLast = (baseFirst = firstRenderPhaseUpdate = null), + _update = _dispatch; do { var updateExpirationTime = _update.expirationTime; - updateExpirationTime < renderExpirationTime$1 - ? (didSkip || - ((didSkip = !0), - (newBaseUpdate = baseUpdate), - (firstRenderPhaseUpdate = newState)), - updateExpirationTime > remainingExpirationTime && - ((remainingExpirationTime = updateExpirationTime), - markUnprocessedUpdateTime(remainingExpirationTime))) - : (markRenderEventTimeAndConfig( + if (updateExpirationTime < renderExpirationTime$1) { + var clone = { + expirationTime: _update.expirationTime, + suspenseConfig: _update.suspenseConfig, + action: _update.action, + eagerReducer: _update.eagerReducer, + eagerState: _update.eagerState, + next: null + }; + null === newBaseQueueLast + ? ((baseFirst = newBaseQueueLast = clone), + (firstRenderPhaseUpdate = newState)) + : (newBaseQueueLast = newBaseQueueLast.next = clone); + updateExpirationTime > currentlyRenderingFiber$1.expirationTime && + ((currentlyRenderingFiber$1.expirationTime = updateExpirationTime), + markUnprocessedUpdateTime(updateExpirationTime)); + } else + null !== newBaseQueueLast && + (newBaseQueueLast = newBaseQueueLast.next = { + expirationTime: 1073741823, + suspenseConfig: _update.suspenseConfig, + action: _update.action, + eagerReducer: _update.eagerReducer, + eagerState: _update.eagerState, + next: null + }), + markRenderEventTimeAndConfig( updateExpirationTime, _update.suspenseConfig ), (newState = _update.eagerReducer === reducer ? _update.eagerState - : reducer(newState, _update.action))); - baseUpdate = _update; + : reducer(newState, _update.action)); _update = _update.next; } while (null !== _update && _update !== _dispatch); - didSkip || - ((newBaseUpdate = baseUpdate), (firstRenderPhaseUpdate = newState)); + null === newBaseQueueLast + ? (firstRenderPhaseUpdate = newState) + : (newBaseQueueLast.next = baseFirst); is$1(newState, hook.memoizedState) || (didReceiveUpdate = !0); hook.memoizedState = newState; - hook.baseUpdate = newBaseUpdate; hook.baseState = firstRenderPhaseUpdate; + hook.baseQueue = newBaseQueueLast; queue.lastRenderedState = newState; } return [hook.memoizedState, queue.dispatch]; @@ -3414,7 +3337,7 @@ function mountState(initialState) { "function" === typeof initialState && (initialState = initialState()); hook.memoizedState = hook.baseState = initialState; initialState = hook.queue = { - last: null, + pending: null, dispatch: null, lastRenderedReducer: basicStateReducer, lastRenderedState: initialState @@ -3431,21 +3354,23 @@ function updateState(initialState) { } function pushEffect(tag, create, destroy, deps) { tag = { tag: tag, create: create, destroy: destroy, deps: deps, next: null }; - null === componentUpdateQueue - ? ((componentUpdateQueue = { lastEffect: null }), - (componentUpdateQueue.lastEffect = tag.next = tag)) - : ((create = componentUpdateQueue.lastEffect), - null === create - ? (componentUpdateQueue.lastEffect = tag.next = tag) - : ((destroy = create.next), - (create.next = tag), - (tag.next = destroy), - (componentUpdateQueue.lastEffect = tag))); + create = currentlyRenderingFiber$1.updateQueue; + null === create + ? ((create = { lastEffect: null }), + (currentlyRenderingFiber$1.updateQueue = create), + (create.lastEffect = tag.next = tag)) + : ((destroy = create.lastEffect), + null === destroy + ? (create.lastEffect = tag.next = tag) + : ((deps = destroy.next), + (destroy.next = tag), + (tag.next = deps), + (create.lastEffect = tag))); return tag; } function mountEffectImpl(fiberEffectTag, hookEffectTag, create, deps) { var hook = mountWorkInProgressHook(); - sideEffectTag |= fiberEffectTag; + currentlyRenderingFiber$1.effectTag |= fiberEffectTag; hook.memoizedState = pushEffect( hookEffectTag, create, @@ -3465,7 +3390,7 @@ function updateEffectImpl(fiberEffectTag, hookEffectTag, create, deps) { return; } } - sideEffectTag |= fiberEffectTag; + currentlyRenderingFiber$1.effectTag |= fiberEffectTag; hook.memoizedState = pushEffect(hookEffectTag, create, destroy, deps); } function mountEffect(create, deps) { @@ -3513,6 +3438,21 @@ function updateCallback(callback, deps) { hook.memoizedState = [callback, deps]; return callback; } +function startTransition(setPending, config, callback) { + var priorityLevel = getCurrentPriorityLevel(); + runWithPriority(98 > priorityLevel ? 98 : priorityLevel, function() { + setPending(!0); + }); + runWithPriority(97 < priorityLevel ? 97 : priorityLevel, function() { + var previousConfig = ReactCurrentBatchConfig$1.suspense; + ReactCurrentBatchConfig$1.suspense = void 0 === config ? null : config; + try { + setPending(!1), callback(); + } finally { + ReactCurrentBatchConfig$1.suspense = previousConfig; + } + }); +} function dispatchAction(fiber, queue, action) { if (!(25 > numberOfReRenders)) throw Error( @@ -3554,14 +3494,11 @@ function dispatchAction(fiber, queue, action) { eagerState: null, next: null }; - var last = queue.last; - if (null === last) suspenseConfig.next = suspenseConfig; - else { - var first = last.next; - null !== first && (suspenseConfig.next = first); - last.next = suspenseConfig; - } - queue.last = suspenseConfig; + var pending = queue.pending; + null === pending + ? (suspenseConfig.next = suspenseConfig) + : ((suspenseConfig.next = pending.next), (pending.next = suspenseConfig)); + queue.pending = suspenseConfig; if ( 0 === fiber.expirationTime && (null === alternate || 0 === alternate.expirationTime) && @@ -3624,7 +3561,7 @@ var ContextOnlyDispatcher = { initialArg = void 0 !== init ? init(initialArg) : initialArg; hook.memoizedState = hook.baseState = initialArg; reducer = hook.queue = { - last: null, + pending: null, dispatch: null, lastRenderedReducer: reducer, lastRenderedState: initialArg @@ -3643,23 +3580,21 @@ var ContextOnlyDispatcher = { }, useState: mountState, useDebugValue: mountDebugValue, - useResponder: createResponderListener, + useResponder: createDeprecatedResponderListener, useDeferredValue: function(value, config) { var _mountState = mountState(value), prevValue = _mountState[0], setValue = _mountState[1]; mountEffect( function() { - Scheduler.unstable_next(function() { - var previousConfig = ReactCurrentBatchConfig$1.suspense; - ReactCurrentBatchConfig$1.suspense = - void 0 === config ? null : config; - try { - setValue(value); - } finally { - ReactCurrentBatchConfig$1.suspense = previousConfig; - } - }); + var previousConfig = ReactCurrentBatchConfig$1.suspense; + ReactCurrentBatchConfig$1.suspense = + void 0 === config ? null : config; + try { + setValue(value); + } finally { + ReactCurrentBatchConfig$1.suspense = previousConfig; + } }, [value, config] ); @@ -3667,25 +3602,13 @@ var ContextOnlyDispatcher = { }, useTransition: function(config) { var _mountState2 = mountState(!1), - isPending = _mountState2[0], - setPending = _mountState2[1]; + isPending = _mountState2[0]; + _mountState2 = _mountState2[1]; return [ - mountCallback( - function(callback) { - setPending(!0); - Scheduler.unstable_next(function() { - var previousConfig = ReactCurrentBatchConfig$1.suspense; - ReactCurrentBatchConfig$1.suspense = - void 0 === config ? null : config; - try { - setPending(!1), callback(); - } finally { - ReactCurrentBatchConfig$1.suspense = previousConfig; - } - }); - }, - [config, isPending] - ), + mountCallback(startTransition.bind(null, _mountState2, config), [ + _mountState2, + config + ]), isPending ]; } @@ -3727,23 +3650,21 @@ var ContextOnlyDispatcher = { }, useState: updateState, useDebugValue: mountDebugValue, - useResponder: createResponderListener, + useResponder: createDeprecatedResponderListener, useDeferredValue: function(value, config) { var _updateState = updateState(value), prevValue = _updateState[0], setValue = _updateState[1]; updateEffect( function() { - Scheduler.unstable_next(function() { - var previousConfig = ReactCurrentBatchConfig$1.suspense; - ReactCurrentBatchConfig$1.suspense = - void 0 === config ? null : config; - try { - setValue(value); - } finally { - ReactCurrentBatchConfig$1.suspense = previousConfig; - } - }); + var previousConfig = ReactCurrentBatchConfig$1.suspense; + ReactCurrentBatchConfig$1.suspense = + void 0 === config ? null : config; + try { + setValue(value); + } finally { + ReactCurrentBatchConfig$1.suspense = previousConfig; + } }, [value, config] ); @@ -3751,25 +3672,13 @@ var ContextOnlyDispatcher = { }, useTransition: function(config) { var _updateState2 = updateState(!1), - isPending = _updateState2[0], - setPending = _updateState2[1]; + isPending = _updateState2[0]; + _updateState2 = _updateState2[1]; return [ - updateCallback( - function(callback) { - setPending(!0); - Scheduler.unstable_next(function() { - var previousConfig = ReactCurrentBatchConfig$1.suspense; - ReactCurrentBatchConfig$1.suspense = - void 0 === config ? null : config; - try { - setPending(!1), callback(); - } finally { - ReactCurrentBatchConfig$1.suspense = previousConfig; - } - }); - }, - [config, isPending] - ), + updateCallback(startTransition.bind(null, _updateState2, config), [ + _updateState2, + config + ]), isPending ]; } @@ -4094,17 +4003,14 @@ function updateClassComponent( )); hasForceUpdate = !1; var oldState = workInProgress.memoizedState; - oldContext = instance.state = oldState; - var updateQueue = workInProgress.updateQueue; - null !== updateQueue && - (processUpdateQueue( - workInProgress, - updateQueue, - nextProps, - instance, - renderExpirationTime - ), - (oldContext = workInProgress.memoizedState)); + instance.state = oldState; + processUpdateQueue( + workInProgress, + nextProps, + instance, + renderExpirationTime + ); + oldContext = workInProgress.memoizedState; oldProps !== nextProps || oldState !== oldContext || didPerformWorkStackCursor.current || @@ -4150,6 +4056,7 @@ function updateClassComponent( (nextProps = !1)); } else (instance = workInProgress.stateNode), + cloneUpdateQueue(current$$1, workInProgress), (oldProps = workInProgress.memoizedProps), (instance.props = workInProgress.type === workInProgress.elementType @@ -4178,17 +4085,14 @@ function updateClassComponent( )), (hasForceUpdate = !1), (oldContext = workInProgress.memoizedState), - (oldState = instance.state = oldContext), - (updateQueue = workInProgress.updateQueue), - null !== updateQueue && - (processUpdateQueue( - workInProgress, - updateQueue, - nextProps, - instance, - renderExpirationTime - ), - (oldState = workInProgress.memoizedState)), + (instance.state = oldContext), + processUpdateQueue( + workInProgress, + nextProps, + instance, + renderExpirationTime + ), + (oldState = workInProgress.memoizedState), oldProps !== nextProps || oldContext !== oldState || didPerformWorkStackCursor.current || @@ -4508,6 +4412,7 @@ function initSuspenseListRenderState( ? (workInProgress.memoizedState = { isBackwards: isBackwards, rendering: null, + renderingStartTime: 0, last: lastContentRow, tail: tail, tailExpiration: 0, @@ -4516,6 +4421,7 @@ function initSuspenseListRenderState( }) : ((renderState.isBackwards = isBackwards), (renderState.rendering = null), + (renderState.renderingStartTime = 0), (renderState.last = lastContentRow), (renderState.tail = tail), (renderState.tailExpiration = 0), @@ -4843,16 +4749,17 @@ updateHostComponent$1 = function(current, workInProgress, type, newProps) { } }; 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.effectTag |= 4)); + oldText !== newText + ? ((current = requiredContext(rootInstanceStackCursor.current)), + (oldText = requiredContext(contextStackCursor$1.current)), + (workInProgress.stateNode = createTextInstance( + newText, + current, + oldText, + workInProgress + )), + (workInProgress.effectTag |= 4)) + : (workInProgress.stateNode = current.stateNode); }; function cutOffTailIfNeeded(renderState, hasRenderedATailFallback) { switch (renderState.tailMode) { @@ -4882,24 +4789,32 @@ function completeWork(current, workInProgress, renderExpirationTime$jscomp$0) { var newProps = workInProgress.pendingProps; switch (workInProgress.tag) { case 2: - break; case 16: - break; case 15: case 0: - break; + case 11: + case 7: + case 8: + case 12: + case 9: + case 14: + return null; case 1: - isContextProvider(workInProgress.type) && popContext(workInProgress); - break; + return ( + isContextProvider(workInProgress.type) && popContext(workInProgress), + null + ); case 3: - popHostContainer(workInProgress); - popTopLevelContextObject(workInProgress); - current = workInProgress.stateNode; - current.pendingContext && - ((current.context = current.pendingContext), - (current.pendingContext = null)); - updateHostContainer(workInProgress); - break; + return ( + popHostContainer(workInProgress), + popTopLevelContextObject(workInProgress), + (current = workInProgress.stateNode), + current.pendingContext && + ((current.context = current.pendingContext), + (current.pendingContext = null)), + updateHostContainer(workInProgress), + null + ); case 5: popHostContext(workInProgress); var rootContainerInstance = requiredContext( @@ -4916,7 +4831,14 @@ function completeWork(current, workInProgress, renderExpirationTime$jscomp$0) { ), current.ref !== workInProgress.ref && (workInProgress.effectTag |= 128); - else if (newProps) { + 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." + ); + return null; + } requiredContext(contextStackCursor$1.current); current = nextReactTag; nextReactTag += 2; @@ -4946,11 +4868,8 @@ function completeWork(current, workInProgress, renderExpirationTime$jscomp$0) { appendAllChildren(current, workInProgress, !1, !1); workInProgress.stateNode = current; null !== workInProgress.ref && (workInProgress.effectTag |= 128); - } else 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." - ); - break; + } + return null; case 6: if (current && null != workInProgress.stateNode) updateHostText$1( @@ -4973,9 +4892,7 @@ function completeWork(current, workInProgress, renderExpirationTime$jscomp$0) { workInProgress ); } - break; - case 11: - break; + return null; case 13: pop(suspenseStackCursor, workInProgress); newProps = workInProgress.memoizedState; @@ -5023,31 +4940,24 @@ function completeWork(current, workInProgress, renderExpirationTime$jscomp$0) { )); } newProps && (workInProgress.effectTag |= 4); - break; - case 7: - break; - case 8: - break; - case 12: - break; + return null; case 4: - popHostContainer(workInProgress); - updateHostContainer(workInProgress); - break; + return ( + popHostContainer(workInProgress), + updateHostContainer(workInProgress), + null + ); case 10: - popProvider(workInProgress); - break; - case 9: - break; - case 14: - break; + return popProvider(workInProgress), null; case 17: - isContextProvider(workInProgress.type) && popContext(workInProgress); - break; + return ( + isContextProvider(workInProgress.type) && popContext(workInProgress), + null + ); case 19: pop(suspenseStackCursor, workInProgress); newProps = workInProgress.memoizedState; - if (null === newProps) break; + if (null === newProps) return null; rootContainerInstance = 0 !== (workInProgress.effectTag & 64); updatePayload = newProps.rendering; if (null === updatePayload) @@ -5142,13 +5052,15 @@ function completeWork(current, workInProgress, renderExpirationTime$jscomp$0) { null === newProps.tail && "hidden" === newProps.tailMode && !updatePayload.alternate) - ) { - workInProgress = workInProgress.lastEffect = newProps.lastEffect; - null !== workInProgress && (workInProgress.nextEffect = null); - break; - } + ) + return ( + (workInProgress = workInProgress.lastEffect = + newProps.lastEffect), + null !== workInProgress && (workInProgress.nextEffect = null), + null + ); } else - now() > newProps.tailExpiration && + 2 * now() - newProps.renderingStartTime > newProps.tailExpiration && 1 < renderExpirationTime$jscomp$0 && ((workInProgress.effectTag |= 64), (rootContainerInstance = !0), @@ -5167,14 +5079,14 @@ function completeWork(current, workInProgress, renderExpirationTime$jscomp$0) { : (workInProgress.child = updatePayload), (newProps.last = updatePayload)); } - if (null !== newProps.tail) - return ( - 0 === newProps.tailExpiration && + return null !== newProps.tail + ? (0 === newProps.tailExpiration && (newProps.tailExpiration = now() + 500), (current = newProps.tail), (newProps.rendering = current), (newProps.tail = current.sibling), (newProps.lastEffect = workInProgress.lastEffect), + (newProps.renderingStartTime = now()), (current.sibling = null), (newProps = suspenseStackCursor.current), push( @@ -5182,21 +5094,14 @@ function completeWork(current, workInProgress, renderExpirationTime$jscomp$0) { rootContainerInstance ? (newProps & 1) | 2 : newProps & 1, workInProgress ), - current - ); - break; - case 20: - break; - case 21: - break; - default: - throw Error( - "Unknown unit of work tag (" + - workInProgress.tag + - "). This error is likely caused by a bug in React. Please file an issue." - ); + current) + : null; } - 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." + ); } function unwindWork(workInProgress) { switch (workInProgress.tag) { @@ -5313,8 +5218,9 @@ function commitBeforeMutationLifeCycles(current$$1, finishedWork) { case 0: case 11: case 15: + case 22: commitHookEffectList(2, 0, finishedWork); - break; + return; case 1: if (finishedWork.effectTag & 256 && null !== current$$1) { var prevProps = current$$1.memoizedProps, @@ -5328,18 +5234,17 @@ function commitBeforeMutationLifeCycles(current$$1, finishedWork) { ); current$$1.__reactInternalSnapshotBeforeUpdate = finishedWork; } - break; + return; case 3: case 5: case 6: case 4: case 17: - 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." - ); + return; } + throw Error( + "This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue." + ); } function commitHookEffectList(unmountTag, mountTag, finishedWork) { finishedWork = finishedWork.updateQueue; @@ -5358,6 +5263,101 @@ function commitHookEffectList(unmountTag, mountTag, finishedWork) { } while (effect !== finishedWork); } } +function commitLifeCycles( + finishedRoot, + current$$1, + finishedWork, + committedExpirationTime +) { + switch (finishedWork.tag) { + case 0: + case 11: + case 15: + case 22: + commitHookEffectList(16, 32, finishedWork); + return; + case 1: + finishedRoot = finishedWork.stateNode; + if (finishedWork.effectTag & 4) + if (null === current$$1) finishedRoot.componentDidMount(); + else { + var prevProps = + finishedWork.elementType === finishedWork.type + ? current$$1.memoizedProps + : resolveDefaultProps( + finishedWork.type, + current$$1.memoizedProps + ); + finishedRoot.componentDidUpdate( + prevProps, + current$$1.memoizedState, + finishedRoot.__reactInternalSnapshotBeforeUpdate + ); + } + current$$1 = finishedWork.updateQueue; + null !== current$$1 && + commitUpdateQueue( + finishedWork, + current$$1, + finishedRoot, + committedExpirationTime + ); + return; + case 3: + current$$1 = finishedWork.updateQueue; + if (null !== current$$1) { + finishedRoot = null; + if (null !== finishedWork.child) + switch (finishedWork.child.tag) { + case 5: + finishedRoot = finishedWork.child.stateNode.canonical; + break; + case 1: + finishedRoot = finishedWork.child.stateNode; + } + commitUpdateQueue( + finishedWork, + current$$1, + finishedRoot, + committedExpirationTime + ); + } + return; + case 5: + if (null === current$$1 && finishedWork.effectTag & 4) + throw Error( + "The current renderer does not support mutation. This error is likely caused by a bug in React. Please file an issue." + ); + return; + case 6: + return; + case 4: + return; + case 12: + committedExpirationTime = finishedWork.memoizedProps.onRender; + "function" === typeof committedExpirationTime && + committedExpirationTime( + finishedWork.memoizedProps.id, + null === current$$1 ? "mount" : "update", + finishedWork.actualDuration, + finishedWork.treeBaseDuration, + finishedWork.actualStartTime, + commitTime, + finishedRoot.memoizedInteractions + ); + return; + case 13: + return; + case 19: + case 17: + case 20: + case 21: + return; + } + throw Error( + "This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue." + ); +} function commitUnmount(finishedRoot, current$$1$jscomp$0, renderPriorityLevel) { "function" === typeof onCommitFiberUnmount && onCommitFiberUnmount(current$$1$jscomp$0); @@ -5366,13 +5366,14 @@ function commitUnmount(finishedRoot, current$$1$jscomp$0, renderPriorityLevel) { case 11: case 14: case 15: + case 22: finishedRoot = current$$1$jscomp$0.updateQueue; if ( null !== finishedRoot && ((finishedRoot = finishedRoot.lastEffect), null !== finishedRoot) ) { var firstEffect = finishedRoot.next; - runWithPriority$1( + runWithPriority( 97 < renderPriorityLevel ? 97 : renderPriorityLevel, function() { var effect = firstEffect; @@ -5420,6 +5421,7 @@ function detachFiber(current$$1) { current$$1.lastEffect = null; current$$1.pendingProps = null; current$$1.memoizedProps = null; + current$$1.stateNode = null; null !== alternate && detachFiber(alternate); } function commitWork(current$$1, finishedWork) { @@ -5428,6 +5430,7 @@ function commitWork(current$$1, finishedWork) { case 11: case 14: case 15: + case 22: commitHookEffectList(4, 8, finishedWork); return; case 12: @@ -5441,19 +5444,20 @@ function commitWork(current$$1, finishedWork) { attachSuspenseRetryListeners(finishedWork); return; } - a: switch (finishedWork.tag) { - case 1: - case 5: - case 6: - case 20: - break a; - case 3: - case 4: - break a; - 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." - ); + a: { + switch (finishedWork.tag) { + case 1: + case 5: + case 6: + case 20: + break a; + case 3: + case 4: + break a; + } + throw Error( + "This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue." + ); } } function attachSuspenseRetryListeners(finishedWork) { @@ -5927,47 +5931,44 @@ function performConcurrentWorkOnRoot(root, didTimeout) { function performSyncWorkOnRoot(root) { var lastExpiredTime = root.lastExpiredTime; lastExpiredTime = 0 !== lastExpiredTime ? lastExpiredTime : 1073741823; - if (root.finishedExpirationTime === lastExpiredTime) commitRoot(root); - else { - if ((executionContext & (RenderContext | CommitContext)) !== NoContext) - throw Error("Should not already be working."); - flushPassiveEffects(); - if (root !== workInProgressRoot || lastExpiredTime !== renderExpirationTime) + if ((executionContext & (RenderContext | CommitContext)) !== NoContext) + throw Error("Should not already be working."); + flushPassiveEffects(); + if (root !== workInProgressRoot || lastExpiredTime !== renderExpirationTime) + prepareFreshStack(root, lastExpiredTime), + startWorkOnPendingInteractions(root, lastExpiredTime); + if (null !== workInProgress) { + var prevExecutionContext = executionContext; + executionContext |= RenderContext; + var prevDispatcher = pushDispatcher(root), + prevInteractions = pushInteractions(root); + do + try { + workLoopSync(); + break; + } catch (thrownValue) { + handleError(root, thrownValue); + } + while (1); + resetContextDependencies(); + executionContext = prevExecutionContext; + ReactCurrentDispatcher.current = prevDispatcher; + tracing.__interactionsRef.current = prevInteractions; + if (workInProgressRootExitStatus === RootFatalErrored) + throw ((prevExecutionContext = workInProgressRootFatalError), prepareFreshStack(root, lastExpiredTime), - startWorkOnPendingInteractions(root, lastExpiredTime); - if (null !== workInProgress) { - var prevExecutionContext = executionContext; - executionContext |= RenderContext; - var prevDispatcher = pushDispatcher(root), - prevInteractions = pushInteractions(root); - do - try { - workLoopSync(); - break; - } catch (thrownValue) { - handleError(root, thrownValue); - } - while (1); - resetContextDependencies(); - executionContext = prevExecutionContext; - ReactCurrentDispatcher.current = prevDispatcher; - tracing.__interactionsRef.current = prevInteractions; - if (workInProgressRootExitStatus === RootFatalErrored) - throw ((prevExecutionContext = workInProgressRootFatalError), - prepareFreshStack(root, lastExpiredTime), - markRootSuspendedAtTime(root, lastExpiredTime), - ensureRootIsScheduled(root), - prevExecutionContext); - if (null !== workInProgress) - throw Error( - "Cannot commit an incomplete root. This error is likely caused by a bug in React. Please file an issue." - ); - root.finishedWork = root.current.alternate; - root.finishedExpirationTime = lastExpiredTime; - workInProgressRoot = null; - commitRoot(root); - ensureRootIsScheduled(root); - } + markRootSuspendedAtTime(root, lastExpiredTime), + ensureRootIsScheduled(root), + prevExecutionContext); + if (null !== workInProgress) + throw Error( + "Cannot commit an incomplete root. This error is likely caused by a bug in React. Please file an issue." + ); + root.finishedWork = root.current.alternate; + root.finishedExpirationTime = lastExpiredTime; + workInProgressRoot = null; + commitRoot(root); + ensureRootIsScheduled(root); } return null; } @@ -6056,8 +6057,15 @@ function handleError(root$jscomp$0, thrownValue) { "object" === typeof value && "function" === typeof value.then ) { - var thenable = value, - hasInvisibleParentBoundary = + var thenable = value; + if (0 === (sourceFiber.mode & 2)) { + var currentSource = sourceFiber.alternate; + currentSource + ? ((sourceFiber.memoizedState = currentSource.memoizedState), + (sourceFiber.expirationTime = currentSource.expirationTime)) + : (sourceFiber.memoizedState = null); + } + var hasInvisibleParentBoundary = 0 !== (suspenseStackCursor.current & 1), _workInProgress = returnFiber; do { @@ -6337,11 +6345,12 @@ function getRemainingExpirationTime(fiber) { } function commitRoot(root) { var renderPriorityLevel = getCurrentPriorityLevel(); - runWithPriority$1(99, commitRootImpl.bind(null, root, renderPriorityLevel)); + runWithPriority(99, commitRootImpl.bind(null, root, renderPriorityLevel)); return null; } function commitRootImpl(root$jscomp$1, renderPriorityLevel$jscomp$1) { - flushPassiveEffects(); + do flushPassiveEffects(); + while (null !== rootWithPendingPassiveEffects); if ((executionContext & (RenderContext | CommitContext)) !== NoContext) throw Error("Should not already be working."); var finishedWork = root$jscomp$1.finishedWork, @@ -6480,108 +6489,24 @@ function commitRootImpl(root$jscomp$1, renderPriorityLevel$jscomp$1) { ) { var effectTag$jscomp$0 = nextEffect.effectTag; - if (effectTag$jscomp$0 & 36) { - renderPriorityLevel = effectTag; - var current$$1$jscomp$1 = nextEffect.alternate; - currentRef = nextEffect; - root = current$$1; - switch (currentRef.tag) { - case 0: - case 11: - case 15: - commitHookEffectList(16, 32, currentRef); - break; - case 1: - var instance = currentRef.stateNode; - if (currentRef.effectTag & 4) - if (null === current$$1$jscomp$1) - instance.componentDidMount(); - else { - var prevProps = - currentRef.elementType === currentRef.type - ? current$$1$jscomp$1.memoizedProps - : resolveDefaultProps( - currentRef.type, - current$$1$jscomp$1.memoizedProps - ); - instance.componentDidUpdate( - prevProps, - current$$1$jscomp$1.memoizedState, - instance.__reactInternalSnapshotBeforeUpdate - ); - } - var updateQueue = currentRef.updateQueue; - null !== updateQueue && - commitUpdateQueue(currentRef, updateQueue, instance, root); - break; - case 3: - var _updateQueue = currentRef.updateQueue; - if (null !== _updateQueue) { - renderPriorityLevel = null; - if (null !== currentRef.child) - switch (currentRef.child.tag) { - case 5: - renderPriorityLevel = - currentRef.child.stateNode.canonical; - break; - case 1: - renderPriorityLevel = currentRef.child.stateNode; - } - commitUpdateQueue( - currentRef, - _updateQueue, - renderPriorityLevel, - root - ); - } - break; - case 5: - if (null === current$$1$jscomp$1 && currentRef.effectTag & 4) - throw Error( - "The current renderer does not support mutation. This error is likely caused by a bug in React. Please file an issue." - ); - break; - case 6: - break; - case 4: - break; - case 12: - var onRender = currentRef.memoizedProps.onRender; - "function" === typeof onRender && - onRender( - currentRef.memoizedProps.id, - null === current$$1$jscomp$1 ? "mount" : "update", - currentRef.actualDuration, - currentRef.treeBaseDuration, - currentRef.actualStartTime, - commitTime, - renderPriorityLevel.memoizedInteractions - ); - break; - case 13: - break; - case 19: - case 17: - case 20: - case 21: - 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." - ); - } - } + effectTag$jscomp$0 & 36 && + commitLifeCycles( + effectTag, + nextEffect.alternate, + nextEffect, + current$$1 + ); if (effectTag$jscomp$0 & 128) { currentRef = void 0; var ref = nextEffect.ref; if (null !== ref) { - var instance$jscomp$0 = nextEffect.stateNode; + var instance = nextEffect.stateNode; switch (nextEffect.tag) { case 5: - currentRef = instance$jscomp$0.canonical; + currentRef = instance.canonical; break; default: - currentRef = instance$jscomp$0; + currentRef = instance; } "function" === typeof ref ? ref(currentRef) @@ -6621,13 +6546,13 @@ function commitRootImpl(root$jscomp$1, renderPriorityLevel$jscomp$1) { for ( remainingExpirationTimeBeforeCommit = spawnedWorkDuringRender, spawnedWorkDuringRender = null, - current$$1$jscomp$1 = 0; - current$$1$jscomp$1 < remainingExpirationTimeBeforeCommit.length; - current$$1$jscomp$1++ + ref = 0; + ref < remainingExpirationTimeBeforeCommit.length; + ref++ ) scheduleInteractions( root$jscomp$1, - remainingExpirationTimeBeforeCommit[current$$1$jscomp$1], + remainingExpirationTimeBeforeCommit[ref], root$jscomp$1.memoizedInteractions ); schedulePendingInteractions(root$jscomp$1, renderPriorityLevel$jscomp$1); @@ -6673,7 +6598,7 @@ function flushPassiveEffects() { ? 97 : pendingPassiveEffectsRenderPriority; pendingPassiveEffectsRenderPriority = 90; - return runWithPriority$1(priorityLevel, flushPassiveEffectsImpl); + return runWithPriority(priorityLevel, flushPassiveEffectsImpl); } } function flushPassiveEffectsImpl() { @@ -6699,6 +6624,7 @@ function flushPassiveEffectsImpl() { case 0: case 11: case 15: + case 22: commitHookEffectList(128, 0, finishedWork), commitHookEffectList(0, 64, finishedWork); } @@ -6921,6 +6847,7 @@ beginWork$$1 = function(current$$1, workInProgress, renderExpirationTime) { null !== renderState.state && void 0 !== renderState.state ? renderState.state : null; + initializeUpdateQueue(workInProgress); var getDerivedStateFromProps = updateExpirationTime.getDerivedStateFromProps; "function" === typeof getDerivedStateFromProps && @@ -6958,62 +6885,63 @@ beginWork$$1 = function(current$$1, workInProgress, renderExpirationTime) { (workInProgress = workInProgress.child); return workInProgress; case 16: - renderState = workInProgress.elementType; - null !== current$$1 && - ((current$$1.alternate = null), - (workInProgress.alternate = null), - (workInProgress.effectTag |= 2)); - current$$1 = workInProgress.pendingProps; - initializeLazyComponentType(renderState); - if (1 !== renderState._status) throw renderState._result; - renderState = renderState._result; - workInProgress.type = renderState; - hasContext = workInProgress.tag = resolveLazyComponentTag(renderState); - current$$1 = resolveDefaultProps(renderState, current$$1); - switch (hasContext) { - case 0: - workInProgress = updateFunctionComponent( - null, - workInProgress, - renderState, - current$$1, - renderExpirationTime - ); - break; - case 1: - workInProgress = updateClassComponent( - null, - workInProgress, - renderState, - current$$1, - renderExpirationTime - ); - break; - case 11: - workInProgress = updateForwardRef( - null, - workInProgress, - renderState, - current$$1, - renderExpirationTime - ); - break; - case 14: - workInProgress = updateMemoComponent( - null, - workInProgress, - renderState, - resolveDefaultProps(renderState.type, current$$1), - updateExpirationTime, - renderExpirationTime - ); - break; - default: - throw Error( - "Element type is invalid. Received a promise that resolves to: " + - renderState + - ". Lazy element type must resolve to a class or function." - ); + a: { + renderState = workInProgress.elementType; + null !== current$$1 && + ((current$$1.alternate = null), + (workInProgress.alternate = null), + (workInProgress.effectTag |= 2)); + current$$1 = workInProgress.pendingProps; + initializeLazyComponentType(renderState); + if (1 !== renderState._status) throw renderState._result; + renderState = renderState._result; + workInProgress.type = renderState; + hasContext = workInProgress.tag = resolveLazyComponentTag(renderState); + current$$1 = resolveDefaultProps(renderState, current$$1); + switch (hasContext) { + case 0: + workInProgress = updateFunctionComponent( + null, + workInProgress, + renderState, + current$$1, + renderExpirationTime + ); + break a; + case 1: + workInProgress = updateClassComponent( + null, + workInProgress, + renderState, + current$$1, + renderExpirationTime + ); + break a; + case 11: + workInProgress = updateForwardRef( + null, + workInProgress, + renderState, + current$$1, + renderExpirationTime + ); + break a; + case 14: + workInProgress = updateMemoComponent( + null, + workInProgress, + renderState, + resolveDefaultProps(renderState.type, current$$1), + updateExpirationTime, + renderExpirationTime + ); + break a; + } + throw Error( + "Element type is invalid. Received a promise that resolves to: " + + renderState + + ". Lazy element type must resolve to a class or function." + ); } return workInProgress; case 0: @@ -7051,16 +6979,17 @@ beginWork$$1 = function(current$$1, workInProgress, renderExpirationTime) { case 3: pushHostRootContext(workInProgress); updateExpirationTime = workInProgress.updateQueue; - if (null === updateExpirationTime) + if (null === current$$1 || null === updateExpirationTime) throw Error( "If the root does not have an updateQueue, we should have already bailed out. This error is likely caused by a bug in React. Please file an issue." ); + updateExpirationTime = workInProgress.pendingProps; renderState = workInProgress.memoizedState; renderState = null !== renderState ? renderState.element : null; + cloneUpdateQueue(current$$1, workInProgress); processUpdateQueue( workInProgress, updateExpirationTime, - workInProgress.pendingProps, null, renderExpirationTime ); @@ -7639,6 +7568,9 @@ function createFiberFromTypeAndProps( fiberTag = 16; owner = null; break a; + case REACT_CHUNK_TYPE: + fiberTag = 22; + break a; } throw Error( "Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: " + @@ -7817,7 +7749,11 @@ function createPortal(children, containerInfo, implementation) { implementation: implementation }; } -var fabricDispatchCommand = nativeFabricUIManager.dispatchCommand; +function _inheritsLoose(subClass, superClass) { + subClass.prototype = Object.create(superClass.prototype); + subClass.prototype.constructor = subClass; + subClass.__proto__ = superClass; +} function findNodeHandle(componentOrHandle) { if (null == componentOrHandle) return null; if ("number" === typeof componentOrHandle) return componentOrHandle; @@ -7958,12 +7894,17 @@ var roots = new Map(), findNodeHandle: findNodeHandle, dispatchCommand: function(handle, command, args) { null != handle._nativeTag && - null != handle._internalInstanceHandle && - fabricDispatchCommand( - handle._internalInstanceHandle.stateNode.node, - command, - args - ); + (handle._internalInstanceHandle + ? nativeFabricUIManager.dispatchCommand( + handle._internalInstanceHandle.stateNode.node, + command, + args + ) + : ReactNativePrivateInterface.UIManager.dispatchViewManagerCommand( + handle._nativeTag, + command, + args + )); }, render: function(element, containerTag, callback) { var root = roots.get(containerTag); @@ -7974,6 +7915,7 @@ var roots = new Map(), uninitializedFiber = createFiber(3, null, null, uninitializedFiber); root.current = uninitializedFiber; uninitializedFiber.stateNode = root; + initializeUpdateQueue(uninitializedFiber); roots.set(containerTag, root); } updateContainer(element, root, null, callback); @@ -8123,7 +8065,7 @@ var roots = new Map(), throw Error("getInspectorDataForViewTag() is not available in production"); }, bundleType: 0, - version: "16.11.0", + version: "16.12.0-19f6fe170", rendererPackageName: "react-native-renderer" }); var ReactFabric$2 = { default: ReactFabric }, diff --git a/Libraries/Renderer/implementations/ReactNativeRenderer-dev.fb.js b/Libraries/Renderer/implementations/ReactNativeRenderer-dev.fb.js index b1ae206b2534e5..ef0fe9a63c622b 100644 --- a/Libraries/Renderer/implementations/ReactNativeRenderer-dev.fb.js +++ b/Libraries/Renderer/implementations/ReactNativeRenderer-dev.fb.js @@ -15,13 +15,110 @@ if (__DEV__) { (function() { "use strict"; +var React = require("react"); require("react-native/Libraries/ReactPrivate/ReactNativePrivateInitializeCore"); var ReactNativePrivateInterface = require("react-native/Libraries/ReactPrivate/ReactNativePrivateInterface"); -var React = require("react"); var checkPropTypes = require("prop-types/checkPropTypes"); var Scheduler = require("scheduler"); var tracing = require("scheduler/tracing"); +var ReactSharedInternals = + React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED; // Prevent newer renderers from RTE when used with older react package versions. +// Current owner and dispatcher used to share the same ref, +// but PR #14548 split them out to better support the react-debug-tools package. + +if (!ReactSharedInternals.hasOwnProperty("ReactCurrentDispatcher")) { + ReactSharedInternals.ReactCurrentDispatcher = { + current: null + }; +} + +if (!ReactSharedInternals.hasOwnProperty("ReactCurrentBatchConfig")) { + ReactSharedInternals.ReactCurrentBatchConfig = { + suspense: null + }; +} + +// by calls to these methods by a Babel plugin. +// +// In PROD (or in packages without access to React internals), +// they are left as they are instead. + +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]; + } + + 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]; + } + + printWarning("error", format, args); + } +} + +function printWarning(level, format, args) { + // When changing this logic, you might want to also + // update consoleWithStackDev.www.js as well. + { + var hasExistingStack = + args.length > 0 && + typeof args[args.length - 1] === "string" && + args[args.length - 1].indexOf("\n in") === 0; + + if (!hasExistingStack) { + var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame; + var stack = ReactDebugCurrentFrame.getStackAddendum(); + + if (stack !== "") { + format += "%s"; + args = args.concat([stack]); + } + } + + var argsWithFormat = args.map(function(item) { + return "" + item; + }); // Careful: RN currently depends on this prefix + + argsWithFormat.unshift("Warning: " + format); // We intentionally don't use spread (or .apply) directly because it + // breaks IE9: https://github.com/facebook/react/issues/13610 + // eslint-disable-next-line react-internal/no-production-logging + + Function.prototype.apply.call(console[level], console, argsWithFormat); + + try { + // --- Welcome to debugging React --- + // This error was thrown as a convenience so that you can use this stack + // to find the callsite that caused this warning to fire. + var argIndex = 0; + var message = + "Warning: " + + format.replace(/%s/g, function() { + return args[argIndex++]; + }); + throw new Error(message); + } catch (x) {} + } +} + /** * Use invariant() to assert state which your program assumes to be true. * @@ -559,71 +656,6 @@ function clearCaughtError() { } } -/** - * Similar to invariant but only logs a warning if the condition is not met. - * This can be used to log issues in development environments in critical - * paths. Removing the logging code for production environments will keep the - * same logic and follow the same code paths. - */ -var warningWithoutStack = function() {}; - -{ - warningWithoutStack = function(condition, format) { - for ( - var _len = arguments.length, - args = new Array(_len > 2 ? _len - 2 : 0), - _key = 2; - _key < _len; - _key++ - ) { - args[_key - 2] = arguments[_key]; - } - - if (format === undefined) { - throw new Error( - "`warningWithoutStack(condition, format, ...args)` requires a warning " + - "message argument" - ); - } - - if (args.length > 8) { - // Check before the condition to catch violations early. - throw new Error( - "warningWithoutStack() currently supports at most 8 arguments." - ); - } - - if (condition) { - return; - } - - if (typeof console !== "undefined") { - var argsWithFormat = args.map(function(item) { - return "" + item; - }); - argsWithFormat.unshift("Warning: " + format); // We intentionally don't use spread (or .apply) directly because it - // breaks IE9: https://github.com/facebook/react/issues/13610 - - Function.prototype.apply.call(console.error, console, argsWithFormat); - } - - try { - // --- Welcome to debugging React --- - // This error was thrown as a convenience so that you can use this stack - // to find the callsite that caused this warning to fire. - var argIndex = 0; - var message = - "Warning: " + - format.replace(/%s/g, function() { - return args[argIndex++]; - }); - throw new Error(message); - } catch (x) {} - }; -} - -var warningWithoutStack$1 = warningWithoutStack; - var getFiberCurrentPropsFromNode = null; var getInstanceFromNode = null; var getNodeFromInstance = null; @@ -637,13 +669,12 @@ function setComponentTree( getNodeFromInstance = getNodeFromInstanceImpl; { - !(getNodeFromInstance && getInstanceFromNode) - ? warningWithoutStack$1( - false, - "EventPluginUtils.setComponentTree(...): Injected " + - "module is missing getNodeFromInstance or getInstanceFromNode." - ) - : void 0; + if (!getNodeFromInstance || !getInstanceFromNode) { + error( + "EventPluginUtils.setComponentTree(...): Injected " + + "module is missing getNodeFromInstance or getInstanceFromNode." + ); + } } } var validateEventDispatches; @@ -664,9 +695,10 @@ var validateEventDispatches; : dispatchInstances ? 1 : 0; - !(instancesIsArr === listenersIsArr && instancesLen === listenersLen) - ? warningWithoutStack$1(false, "EventPluginUtils: Invalid `event`.") - : void 0; + + if (instancesIsArr !== listenersIsArr || instancesLen !== listenersLen) { + error("EventPluginUtils: Invalid `event`."); + } }; } /** @@ -1093,6 +1125,7 @@ var DehydratedFragment = 18; var SuspenseListComponent = 19; var FundamentalComponent = 20; var ScopeComponent = 21; +var Chunk = 22; function getParent(inst) { do { @@ -1230,9 +1263,9 @@ function listenerAtPhase(inst, event, propagationPhase) { function accumulateDirectionalDispatches(inst, phase, event) { { - !inst - ? warningWithoutStack$1(false, "Dispatching inst must not be null") - : void 0; + if (!inst) { + error("Dispatching inst must not be null"); + } } var listener = listenerAtPhase(inst, event, phase); @@ -1577,7 +1610,7 @@ function getPooledWarningPropertyDefinition(propName, getVal) { function set(val) { var action = isFunction ? "setting the method" : "setting the property"; - warn(action, "This is effectively a no-op"); + warn$$1(action, "This is effectively a no-op"); return val; } @@ -1586,24 +1619,22 @@ function getPooledWarningPropertyDefinition(propName, getVal) { var result = isFunction ? "This is a no-op function" : "This is set to null"; - warn(action, result); + warn$$1(action, result); return getVal; } - function warn(action, result) { - var warningCondition = false; - !warningCondition - ? warningWithoutStack$1( - false, - "This synthetic event is reused for performance reasons. If you're seeing this, " + - "you're %s `%s` on a released/nullified synthetic event. %s. " + - "If you must keep the original synthetic event around, use event.persist(). " + - "See https://fb.me/react-event-pooling for more information.", - action, - propName, - result - ) - : void 0; + function warn$$1(action, result) { + { + error( + "This synthetic event is reused for performance reasons. If you're seeing this, " + + "you're %s `%s` on a released/nullified synthetic event. %s. " + + "If you must keep the original synthetic event around, use event.persist(). " + + "See https://fb.me/react-event-pooling for more information.", + action, + propName, + result + ); + } } } @@ -1748,15 +1779,14 @@ function getTouchIdentifier(_ref) { } { - !(identifier <= MAX_TOUCH_BANK) - ? warningWithoutStack$1( - false, - "Touch identifier %s is greater than maximum supported %s which causes " + - "performance issues backfilling array locations for all of the indices.", - identifier, - MAX_TOUCH_BANK - ) - : void 0; + if (identifier > MAX_TOUCH_BANK) { + error( + "Touch identifier %s is greater than maximum supported %s which causes " + + "performance issues backfilling array locations for all of the indices.", + identifier, + MAX_TOUCH_BANK + ); + } } return identifier; @@ -1788,12 +1818,15 @@ function recordTouchMove(touch) { touchRecord.currentTimeStamp = timestampForTouch(touch); touchHistory.mostRecentTimeStamp = timestampForTouch(touch); } else { - console.warn( - "Cannot record touch move without a touch start.\n" + "Touch Move: %s\n", - "Touch Bank: %s", - printTouch(touch), - printTouchBank() - ); + { + warn( + "Cannot record touch move without a touch start.\n" + + "Touch Move: %s\n" + + "Touch Bank: %s", + printTouch(touch), + printTouchBank() + ); + } } } @@ -1810,12 +1843,15 @@ function recordTouchEnd(touch) { touchRecord.currentTimeStamp = timestampForTouch(touch); touchHistory.mostRecentTimeStamp = timestampForTouch(touch); } else { - console.warn( - "Cannot record touch end without a touch start.\n" + "Touch End: %s\n", - "Touch Bank: %s", - printTouch(touch), - printTouchBank() - ); + { + warn( + "Cannot record touch end without a touch start.\n" + + "Touch End: %s\n" + + "Touch Bank: %s", + printTouch(touch), + printTouchBank() + ); + } } } @@ -1866,9 +1902,10 @@ var ResponderTouchHistoryStore = { { var activeRecord = touchBank[touchHistory.indexOfSingleActiveTouch]; - !(activeRecord != null && activeRecord.touchActive) - ? warningWithoutStack$1(false, "Cannot find single active touch.") - : void 0; + + if (activeRecord == null || !activeRecord.touchActive) { + error("Cannot find single active touch."); + } } } } @@ -2397,9 +2434,12 @@ var ResponderEventPlugin = { if (trackedTouchCount >= 0) { trackedTouchCount -= 1; } else { - console.warn( - "Ended a touch event which was not counted in `trackedTouchCount`." - ); + { + warn( + "Ended a touch event which was not counted in `trackedTouchCount`." + ); + } + return null; } } @@ -2575,11 +2615,13 @@ var enableProfilerTimer = true; var enableSchedulerTracing = true; var enableSuspenseServerRenderer = false; +var enableChunksAPI = false; + var debugRenderPhaseSideEffectsForStrictMode = true; var replayFailedUnitOfWorkWithInvokeGuardedCallback = true; var warnAboutDeprecatedLifecycles = true; -var enableFlareAPI = false; +var enableDeprecatedFlareAPI = false; var enableFundamentalAPI = false; var enableScopeAPI = false; @@ -2590,6 +2632,7 @@ var warnAboutDefaultPropsOnFunctionComponents = false; var warnAboutStringRefs = false; var disableLegacyContext = false; var disableSchedulerTimeoutBasedOnReactExpirationTime = false; +var enableTrainModelFix = false; // Only used in www builds. // Flow magic to verify the exports of this file match the original version. @@ -2667,8 +2710,13 @@ function restoreStateOfTarget(target) { ); } - var props = getFiberCurrentPropsFromNode(internalInstance.stateNode); - restoreImpl(internalInstance.stateNode, internalInstance.type, props); + var stateNode = internalInstance.stateNode; // Guard against Fiber being unmounted. + + if (stateNode) { + var _props = getFiberCurrentPropsFromNode(stateNode); + + restoreImpl(internalInstance.stateNode, internalInstance.type, _props); + } } function needsStateRestore() { @@ -2901,10 +2949,7 @@ function receiveTouches(eventTopLevelType, touches, changedIndices) { if (target !== null && target !== undefined) { if (target < 1) { { - warningWithoutStack$1( - false, - "A view is reporting that a touch occurred on tag zero." - ); + error("A view is reporting that a touch occurred on tag zero."); } } else { rootNodeID = target; @@ -2971,23 +3016,6 @@ function set(key, value) { key._reactInternalFiber = value; } -var ReactSharedInternals = - React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED; // Prevent newer renderers from RTE when used with older react package versions. -// Current owner and dispatcher used to share the same ref, -// but PR #14548 split them out to better support the react-debug-tools package. - -if (!ReactSharedInternals.hasOwnProperty("ReactCurrentDispatcher")) { - ReactSharedInternals.ReactCurrentDispatcher = { - current: null - }; -} - -if (!ReactSharedInternals.hasOwnProperty("ReactCurrentBatchConfig")) { - ReactSharedInternals.ReactCurrentBatchConfig = { - suspense: null - }; -} - // The Symbol used to tag the ReactElement-like types. If there is no native Symbol // nor polyfill, then a plain number is used for performance. var hasSymbol = typeof Symbol === "function" && Symbol.for; @@ -3014,6 +3042,7 @@ var REACT_SUSPENSE_LIST_TYPE = hasSymbol : 0xead8; var REACT_MEMO_TYPE = hasSymbol ? Symbol.for("react.memo") : 0xead3; var REACT_LAZY_TYPE = hasSymbol ? Symbol.for("react.lazy") : 0xead4; +var REACT_CHUNK_TYPE = hasSymbol ? Symbol.for("react.chunk") : 0xead9; var REACT_FUNDAMENTAL_TYPE = hasSymbol ? Symbol.for("react.fundamental") : 0xead5; @@ -3037,43 +3066,6 @@ function getIteratorFn(maybeIterable) { return null; } -/** - * Similar to invariant but only logs a warning if the condition is not met. - * This can be used to log issues in development environments in critical - * paths. Removing the logging code for production environments will keep the - * same logic and follow the same code paths. - */ - -var warning = warningWithoutStack$1; - -{ - warning = function(condition, format) { - if (condition) { - return; - } - - var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame; - var stack = ReactDebugCurrentFrame.getStackAddendum(); // eslint-disable-next-line react-internal/warning-and-invariant-args - - for ( - var _len = arguments.length, - args = new Array(_len > 2 ? _len - 2 : 0), - _key = 2; - _key < _len; - _key++ - ) { - args[_key - 2] = arguments[_key]; - } - - warningWithoutStack$1.apply( - void 0, - [false, format + "%s"].concat(args, [stack]) - ); - }; -} - -var warning$1 = warning; - var Uninitialized = -1; var Pending = 0; var Resolved = 1; @@ -3094,8 +3086,7 @@ function initializeLazyComponentType(lazyComponent) { { if (defaultExport === undefined) { - warning$1( - false, + error( "lazy: Expected the result of a dynamic import() call. " + "Instead received: %s\n\nYour code should look like: \n " + "const MyComponent = lazy(() => import('./MyComponent'))", @@ -3108,10 +3099,10 @@ function initializeLazyComponentType(lazyComponent) { lazyComponent._result = defaultExport; } }, - function(error) { + function(error$$1) { if (lazyComponent._status === Pending) { lazyComponent._status = Rejected; - lazyComponent._result = error; + lazyComponent._result = error$$1; } } ); @@ -3134,8 +3125,7 @@ function getComponentName(type) { { if (typeof type.tag === "number") { - warningWithoutStack$1( - false, + error( "Received an unexpected object in getComponentName(). " + "This is likely a bug in React. Please file an issue." ); @@ -3184,6 +3174,9 @@ function getComponentName(type) { case REACT_MEMO_TYPE: return getComponentName(type.type); + case REACT_CHUNK_TYPE: + return getComponentName(type.render); + case REACT_LAZY_TYPE: { var thenable = type; var resolvedThenable = refineResolvedLazyComponent(thenable); @@ -3307,17 +3300,18 @@ function isMounted(component) { if (owner !== null && owner.tag === ClassComponent) { var ownerFiber = owner; var instance = ownerFiber.stateNode; - !instance._warnedAboutRefsInRender - ? warningWithoutStack$1( - false, - "%s is accessing isMounted inside its render() function. " + - "render() should be a pure function of props and state. It should " + - "never access something that requires stale data from the previous " + - "render, such as refs. Move this logic to componentDidMount and " + - "componentDidUpdate instead.", - getComponentName(ownerFiber.type) || "A component" - ) - : void 0; + + if (!instance._warnedAboutRefsInRender) { + error( + "%s is accessing isMounted inside its render() function. " + + "render() should be a pure function of props and state. It should " + + "never access something that requires stale data from the previous " + + "render, such as refs. Move this logic to componentDidMount and " + + "componentDidUpdate instead.", + getComponentName(ownerFiber.type) || "A component" + ); + } + instance._warnedAboutRefsInRender = true; } } @@ -4042,17 +4036,19 @@ function throwOnStylesProp(component, props) { } } function warnForStyleProps(props, validAttributes) { - for (var key in validAttributes.style) { - if (!(validAttributes[key] || props[key] === undefined)) { - console.error( - "You are setting the style `{ " + - key + - ": ... }` as a prop. You " + - "should nest it in a style object. " + - "E.g. `{ style: { " + - key + - ": ... } }`" - ); + { + for (var key in validAttributes.style) { + if (!(validAttributes[key] || props[key] === undefined)) { + error( + "You are setting the style `{ %s" + + ": ... }` as a prop. You " + + "should nest it in a style object. " + + "E.g. `{ style: { %s" + + ": ... } }`", + key, + key + ); + } } } } @@ -4117,10 +4113,12 @@ var ReactNativeFiberHostComponent = } if (relativeNode == null) { - warningWithoutStack$1( - false, - "Warning: ref.measureLayout must be called with a node handle or a ref to a native component." - ); + { + error( + "Warning: ref.measureLayout must be called with a node handle or a ref to a native component." + ); + } + return; } @@ -4568,7 +4566,7 @@ function unhideInstance(instance, props) { function unhideTextInstance(textInstance, text) { throw new Error("Not yet implemented."); } -function mountResponderInstance( +function DEPRECATED_mountResponderInstance( responder, responderInstance, props, @@ -4577,7 +4575,7 @@ function mountResponderInstance( ) { throw new Error("Not yet implemented."); } -function unmountResponderInstance(responderInstance) { +function DEPRECATED_unmountResponderInstance(responderInstance) { throw new Error("Not yet implemented."); } function getFundamentalComponentInstance(fundamentalInstance) { @@ -4598,6 +4596,9 @@ function unmountFundamentalComponent(fundamentalInstance) { function getInstanceFromNode$1(node) { throw new Error("Not yet implemented."); } +function beforeRemoveInstance(instance) { + // noop +} var BEFORE_SLASH_RE = /^(.*)[\\\/]/; var describeComponentFrame = function(name, source, ownerName) { @@ -5181,7 +5182,7 @@ function createCursor(defaultValue) { function pop(cursor, fiber) { if (index < 0) { { - warningWithoutStack$1(false, "Unexpected pop."); + error("Unexpected pop."); } return; @@ -5189,7 +5190,7 @@ function pop(cursor, fiber) { { if (fiber !== fiberStack[index]) { - warningWithoutStack$1(false, "Unexpected Fiber popped."); + error("Unexpected Fiber popped."); } } @@ -5376,8 +5377,8 @@ function processChildContext(fiber, type, parentContext) { if (!warnedAboutMissingGetChildContext[componentName]) { warnedAboutMissingGetChildContext[componentName] = true; - warningWithoutStack$1( - false, + + error( "%s.childContextTypes is specified but there is no getChildContext() method " + "on the instance. You can either define getChildContext() on %s or remove " + "childContextTypes from it.", @@ -5896,78 +5897,6 @@ function shallowEqual(objA, objB) { return true; } -/** - * Forked from fbjs/warning: - * https://github.com/facebook/fbjs/blob/e66ba20ad5be433eb54423f2b097d829324d9de6/packages/fbjs/src/__forks__/warning.js - * - * Only change is we use console.warn instead of console.error, - * and do nothing when 'console' is not supported. - * This really simplifies the code. - * --- - * Similar to invariant but only logs a warning if the condition is not met. - * This can be used to log issues in development environments in critical - * paths. Removing the logging code for production environments will keep the - * same logic and follow the same code paths. - */ -var lowPriorityWarningWithoutStack = function() {}; - -{ - var printWarning = function(format) { - for ( - var _len = arguments.length, - args = new Array(_len > 1 ? _len - 1 : 0), - _key = 1; - _key < _len; - _key++ - ) { - args[_key - 1] = arguments[_key]; - } - - var argIndex = 0; - var message = - "Warning: " + - format.replace(/%s/g, function() { - return args[argIndex++]; - }); - - if (typeof console !== "undefined") { - console.warn(message); - } - - try { - // --- Welcome to debugging React --- - // This error was thrown as a convenience so that you can use this stack - // to find the callsite that caused this warning to fire. - throw new Error(message); - } catch (x) {} - }; - - lowPriorityWarningWithoutStack = function(condition, format) { - if (format === undefined) { - throw new Error( - "`lowPriorityWarningWithoutStack(condition, format, ...args)` requires a warning " + - "message argument" - ); - } - - if (!condition) { - for ( - var _len2 = arguments.length, - args = new Array(_len2 > 2 ? _len2 - 2 : 0), - _key2 = 2; - _key2 < _len2; - _key2++ - ) { - args[_key2 - 2] = arguments[_key2]; - } - - printWarning.apply(void 0, [format].concat(args)); - } - }; -} - -var lowPriorityWarningWithoutStack$1 = lowPriorityWarningWithoutStack; - var ReactStrictModeWarnings = { recordUnsafeLifecycleWarnings: function(fiber, instance) {}, flushPendingUnsafeLifecycleWarnings: function() {}, @@ -6138,8 +6067,8 @@ var ReactStrictModeWarnings = { if (UNSAFE_componentWillMountUniqueNames.size > 0) { var sortedNames = setToSortedString(UNSAFE_componentWillMountUniqueNames); - warningWithoutStack$1( - false, + + error( "Using UNSAFE_componentWillMount in strict mode is not recommended and may indicate bugs in your code. " + "See https://fb.me/react-unsafe-component-lifecycles for details.\n\n" + "* Move code with side effects to componentDidMount, and set initial state in the constructor.\n" + @@ -6153,8 +6082,7 @@ var ReactStrictModeWarnings = { UNSAFE_componentWillReceivePropsUniqueNames ); - warningWithoutStack$1( - false, + error( "Using UNSAFE_componentWillReceiveProps in strict mode is not recommended " + "and may indicate bugs in your code. " + "See https://fb.me/react-unsafe-component-lifecycles for details.\n\n" + @@ -6172,8 +6100,7 @@ var ReactStrictModeWarnings = { UNSAFE_componentWillUpdateUniqueNames ); - warningWithoutStack$1( - false, + error( "Using UNSAFE_componentWillUpdate in strict mode is not recommended " + "and may indicate bugs in your code. " + "See https://fb.me/react-unsafe-component-lifecycles for details.\n\n" + @@ -6186,8 +6113,7 @@ var ReactStrictModeWarnings = { if (componentWillMountUniqueNames.size > 0) { var _sortedNames3 = setToSortedString(componentWillMountUniqueNames); - lowPriorityWarningWithoutStack$1( - false, + warn( "componentWillMount has been renamed, and is not recommended for use. " + "See https://fb.me/react-unsafe-component-lifecycles for details.\n\n" + "* Move code with side effects to componentDidMount, and set initial state in the constructor.\n" + @@ -6205,8 +6131,7 @@ var ReactStrictModeWarnings = { componentWillReceivePropsUniqueNames ); - lowPriorityWarningWithoutStack$1( - false, + warn( "componentWillReceiveProps has been renamed, and is not recommended for use. " + "See https://fb.me/react-unsafe-component-lifecycles for details.\n\n" + "* Move data fetching code or side effects to componentDidUpdate.\n" + @@ -6225,8 +6150,7 @@ var ReactStrictModeWarnings = { if (componentWillUpdateUniqueNames.size > 0) { var _sortedNames5 = setToSortedString(componentWillUpdateUniqueNames); - lowPriorityWarningWithoutStack$1( - false, + warn( "componentWillUpdate has been renamed, and is not recommended for use. " + "See https://fb.me/react-unsafe-component-lifecycles for details.\n\n" + "* Move data fetching code or side effects to componentDidUpdate.\n" + @@ -6251,11 +6175,11 @@ var ReactStrictModeWarnings = { var strictRoot = findStrictRoot(fiber); if (strictRoot === null) { - warningWithoutStack$1( - false, + error( "Expected to find a StrictMode component in a strict mode tree. " + "This error is likely caused by a bug in React. Please file an issue." ); + return; } // Dedup strategy: Warn once per component. @@ -6288,8 +6212,8 @@ var ReactStrictModeWarnings = { }); var sortedNames = setToSortedString(uniqueNames); var strictRootComponentStack = getStackByFiberInDevAndProd(strictRoot); - warningWithoutStack$1( - false, + + error( "Legacy context API has been detected within a strict-mode tree." + "\n\nThe old API will be supported in all 16.x releases, but applications " + "using it should migrate to the new version." + @@ -6822,17 +6746,17 @@ function pushProvider(providerFiber, nextValue) { context._currentValue = nextValue; { - !( - context._currentRenderer === undefined || - context._currentRenderer === null || - context._currentRenderer === rendererSigil - ) - ? warningWithoutStack$1( - false, - "Detected multiple renderers concurrently rendering the " + - "same context provider. This is currently unsupported." - ) - : void 0; + if ( + context._currentRenderer !== undefined && + context._currentRenderer !== null && + context._currentRenderer !== rendererSigil + ) { + error( + "Detected multiple renderers concurrently rendering the " + + "same context provider. This is currently unsupported." + ); + } + context._currentRenderer = rendererSigil; } } else { @@ -6840,17 +6764,17 @@ function pushProvider(providerFiber, nextValue) { context._currentValue2 = nextValue; { - !( - context._currentRenderer2 === undefined || - context._currentRenderer2 === null || - context._currentRenderer2 === rendererSigil - ) - ? warningWithoutStack$1( - false, - "Detected multiple renderers concurrently rendering the " + - "same context provider. This is currently unsupported." - ) - : void 0; + if ( + context._currentRenderer2 !== undefined && + context._currentRenderer2 !== null && + context._currentRenderer2 !== rendererSigil + ) { + error( + "Detected multiple renderers concurrently rendering the " + + "same context provider. This is currently unsupported." + ); + } + context._currentRenderer2 = rendererSigil; } } @@ -6877,14 +6801,13 @@ function calculateChangedBits(context, newValue, oldValue) { : MAX_SIGNED_31_BIT_INT; { - !((changedBits & MAX_SIGNED_31_BIT_INT) === changedBits) - ? warning$1( - false, - "calculateChangedBits: Expected the return value to be a " + - "31-bit integer. Instead received: %s", - changedBits - ) - : void 0; + if ((changedBits & MAX_SIGNED_31_BIT_INT) !== changedBits) { + error( + "calculateChangedBits: Expected the return value to be a " + + "31-bit integer. Instead received: %s", + changedBits + ); + } } return changedBits | 0; @@ -7080,15 +7003,14 @@ function readContext(context, observedBits) { { // This warning would fire if you read context inside a Hook like useMemo. // Unlike the class check below, it's not enforced in production for perf. - !!isDisallowedContextReadInDEV - ? warning$1( - false, - "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()." - ) - : void 0; + if (isDisallowedContextReadInDEV) { + 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 (lastContextWithAllBitsObserved === context) { @@ -7229,38 +7151,32 @@ var currentlyProcessingQueue; currentlyProcessingQueue = null; } -function createUpdateQueue(baseState) { +function initializeUpdateQueue(fiber) { var queue = { - baseState: baseState, - firstUpdate: null, - lastUpdate: null, - firstCapturedUpdate: null, - lastCapturedUpdate: null, - firstEffect: null, - lastEffect: null, - firstCapturedEffect: null, - lastCapturedEffect: null - }; - return queue; -} - -function cloneUpdateQueue(currentQueue) { - var queue = { - baseState: currentQueue.baseState, - firstUpdate: currentQueue.firstUpdate, - lastUpdate: currentQueue.lastUpdate, - // TODO: With resuming, if we bail out and resuse the child tree, we should - // keep these effects. - firstCapturedUpdate: null, - lastCapturedUpdate: null, - firstEffect: null, - lastEffect: null, - firstCapturedEffect: null, - lastCapturedEffect: null + baseState: fiber.memoizedState, + baseQueue: null, + shared: { + pending: null + }, + effects: null }; - return queue; + fiber.updateQueue = queue; +} +function cloneUpdateQueue(current, workInProgress) { + // Clone the update queue from current. Unless it's already a clone. + var queue = workInProgress.updateQueue; + var currentQueue = current.updateQueue; + + if (queue === currentQueue) { + var clone = { + baseState: currentQueue.baseState, + baseQueue: currentQueue.baseQueue, + shared: currentQueue.shared, + effects: currentQueue.effects + }; + workInProgress.updateQueue = clone; + } } - function createUpdate(expirationTime, suspenseConfig) { var update = { expirationTime: expirationTime, @@ -7268,9 +7184,9 @@ function createUpdate(expirationTime, suspenseConfig) { tag: UpdateState, payload: null, callback: null, - next: null, - nextEffect: null + next: null }; + update.next = update; { update.priority = getCurrentPriorityLevel(); @@ -7278,136 +7194,62 @@ function createUpdate(expirationTime, suspenseConfig) { return update; } +function enqueueUpdate(fiber, update) { + var updateQueue = fiber.updateQueue; -function appendUpdateToQueue(queue, update) { - // Append the update to the end of the list. - if (queue.lastUpdate === null) { - // Queue is empty - queue.firstUpdate = queue.lastUpdate = update; - } else { - queue.lastUpdate.next = update; - queue.lastUpdate = update; + if (updateQueue === null) { + // Only occurs if the fiber has been unmounted. + return; } -} -function enqueueUpdate(fiber, update) { - // Update queues are created lazily. - var alternate = fiber.alternate; - var queue1; - var queue2; + var sharedQueue = updateQueue.shared; + var pending = sharedQueue.pending; - if (alternate === null) { - // There's only one fiber. - queue1 = fiber.updateQueue; - queue2 = null; - - if (queue1 === null) { - queue1 = fiber.updateQueue = createUpdateQueue(fiber.memoizedState); - } + if (pending === null) { + // This is the first update. Create a circular list. + update.next = update; } else { - // There are two owners. - queue1 = fiber.updateQueue; - queue2 = alternate.updateQueue; - - if (queue1 === null) { - if (queue2 === null) { - // Neither fiber has an update queue. Create new ones. - queue1 = fiber.updateQueue = createUpdateQueue(fiber.memoizedState); - queue2 = alternate.updateQueue = createUpdateQueue( - alternate.memoizedState - ); - } else { - // Only one fiber has an update queue. Clone to create a new one. - queue1 = fiber.updateQueue = cloneUpdateQueue(queue2); - } - } else { - if (queue2 === null) { - // Only one fiber has an update queue. Clone to create a new one. - queue2 = alternate.updateQueue = cloneUpdateQueue(queue1); - } else { - // Both owners have an update queue. - } - } + update.next = pending.next; + pending.next = update; } - if (queue2 === null || queue1 === queue2) { - // There's only a single queue. - appendUpdateToQueue(queue1, update); - } else { - // There are two queues. We need to append the update to both queues, - // while accounting for the persistent structure of the list — we don't - // want the same update to be added multiple times. - if (queue1.lastUpdate === null || queue2.lastUpdate === null) { - // One of the queues is not empty. We must add the update to both queues. - appendUpdateToQueue(queue1, update); - appendUpdateToQueue(queue2, update); - } else { - // Both queues are non-empty. The last update is the same in both lists, - // because of structural sharing. So, only append to one of the lists. - appendUpdateToQueue(queue1, update); // But we still need to update the `lastUpdate` pointer of queue2. - - queue2.lastUpdate = update; - } - } + sharedQueue.pending = update; { if ( - fiber.tag === ClassComponent && - (currentlyProcessingQueue === queue1 || - (queue2 !== null && currentlyProcessingQueue === queue2)) && + currentlyProcessingQueue === sharedQueue && !didWarnUpdateInsideUpdate ) { - warningWithoutStack$1( - false, + error( "An update (setState, replaceState, or forceUpdate) was scheduled " + "from inside an update function. Update functions should be pure, " + "with zero side-effects. Consider using componentDidUpdate or a " + "callback." ); + didWarnUpdateInsideUpdate = true; } } } function enqueueCapturedUpdate(workInProgress, update) { - // Captured updates go into a separate list, and only on the work-in- - // progress queue. - var workInProgressQueue = workInProgress.updateQueue; + var current = workInProgress.alternate; - if (workInProgressQueue === null) { - workInProgressQueue = workInProgress.updateQueue = createUpdateQueue( - workInProgress.memoizedState - ); - } else { - // TODO: I put this here rather than createWorkInProgress so that we don't - // clone the queue unnecessarily. There's probably a better way to - // structure this. - workInProgressQueue = ensureWorkInProgressQueueIsAClone( - workInProgress, - workInProgressQueue - ); - } // Append the update to the end of the list. + if (current !== null) { + // Ensure the work-in-progress queue is a clone + cloneUpdateQueue(current, workInProgress); + } // Captured updates go only on the work-in-progress queue. - if (workInProgressQueue.lastCapturedUpdate === null) { - // This is the first render phase update - workInProgressQueue.firstCapturedUpdate = workInProgressQueue.lastCapturedUpdate = update; - } else { - workInProgressQueue.lastCapturedUpdate.next = update; - workInProgressQueue.lastCapturedUpdate = update; - } -} + var queue = workInProgress.updateQueue; // Append the update to the end of the list. -function ensureWorkInProgressQueueIsAClone(workInProgress, queue) { - var current = workInProgress.alternate; + var last = queue.baseQueue; - if (current !== null) { - // If the work-in-progress queue is equal to the current queue, - // we need to clone it first. - if (queue === current.updateQueue) { - queue = workInProgress.updateQueue = cloneUpdateQueue(queue); - } + if (last === null) { + queue.baseQueue = update.next = update; + update.next = update; + } else { + update.next = last.next; + last.next = update; } - - return queue; } function getStateFromUpdate( @@ -7499,163 +7341,171 @@ function getStateFromUpdate( function processUpdateQueue( workInProgress, - queue, props, instance, renderExpirationTime ) { + // This is always non-null on a ClassComponent or HostRoot + var queue = workInProgress.updateQueue; hasForceUpdate = false; - queue = ensureWorkInProgressQueueIsAClone(workInProgress, queue); { - currentlyProcessingQueue = queue; - } // These values may change as we process the queue. + currentlyProcessingQueue = queue.shared; + } // The last rebase update that is NOT part of the base state. + + var baseQueue = queue.baseQueue; // The last pending update that hasn't been processed yet. - var newBaseState = queue.baseState; - var newFirstUpdate = null; - var newExpirationTime = NoWork; // Iterate through the list of updates to compute the result. + var pendingQueue = queue.shared.pending; - var update = queue.firstUpdate; - var resultState = newBaseState; + if (pendingQueue !== null) { + // We have new updates that haven't been processed yet. + // We'll add them to the base queue. + if (baseQueue !== null) { + // Merge the pending queue and the base queue. + var baseFirst = baseQueue.next; + var pendingFirst = pendingQueue.next; + baseQueue.next = pendingFirst; + pendingQueue.next = baseFirst; + } - while (update !== null) { - var updateExpirationTime = update.expirationTime; + baseQueue = pendingQueue; + queue.shared.pending = null; // TODO: Pass `current` as argument - if (updateExpirationTime < renderExpirationTime) { - // This update does not have sufficient priority. Skip it. - if (newFirstUpdate === null) { - // This is the first skipped update. It will be the first update in - // the new list. - newFirstUpdate = update; // Since this is the first update that was skipped, the current result - // is the new base state. + var current = workInProgress.alternate; - newBaseState = resultState; - } // Since this update will remain in the list, update the remaining - // expiration time. + if (current !== null) { + var currentQueue = current.updateQueue; - if (newExpirationTime < updateExpirationTime) { - newExpirationTime = updateExpirationTime; + if (currentQueue !== null) { + currentQueue.baseQueue = pendingQueue; } - } else { - // This update does have sufficient priority. - // Mark the event time of this update as relevant to this render pass. - // TODO: This should ideally use the true event time of this update rather than - // its priority which is a derived and not reverseable value. - // TODO: We should skip this update if it was already committed but currently - // we have no way of detecting the difference between a committed and suspended - // update here. - markRenderEventTimeAndConfig(updateExpirationTime, update.suspenseConfig); // Process it and compute a new result. - - resultState = getStateFromUpdate( - workInProgress, - queue, - update, - resultState, - props, - instance - ); - var callback = update.callback; + } + } // These values may change as we process the queue. - if (callback !== null) { - workInProgress.effectTag |= Callback; // Set this to null, in case it was mutated during an aborted render. + if (baseQueue !== null) { + var first = baseQueue.next; // Iterate through the list of updates to compute the result. - update.nextEffect = null; + var newState = queue.baseState; + var newExpirationTime = NoWork; + var newBaseState = null; + var newBaseQueueFirst = null; + var newBaseQueueLast = null; - if (queue.lastEffect === null) { - queue.firstEffect = queue.lastEffect = update; - } else { - queue.lastEffect.nextEffect = update; - queue.lastEffect = update; - } - } - } // Continue to the next update. + if (first !== null) { + var update = first; - update = update.next; - } // Separately, iterate though the list of captured updates. + do { + var updateExpirationTime = update.expirationTime; + + if (updateExpirationTime < renderExpirationTime) { + // Priority is insufficient. Skip this update. If this is the first + // skipped update, the previous update/state is the new base + // update/state. + var clone = { + expirationTime: update.expirationTime, + suspenseConfig: update.suspenseConfig, + tag: update.tag, + payload: update.payload, + callback: update.callback, + next: null + }; - var newFirstCapturedUpdate = null; - update = queue.firstCapturedUpdate; + if (newBaseQueueLast === null) { + newBaseQueueFirst = newBaseQueueLast = clone; + newBaseState = newState; + } else { + newBaseQueueLast = newBaseQueueLast.next = clone; + } // Update the remaining priority in the queue. - while (update !== null) { - var _updateExpirationTime = update.expirationTime; + if (updateExpirationTime > newExpirationTime) { + newExpirationTime = updateExpirationTime; + } + } else { + // This update does have sufficient priority. + if (newBaseQueueLast !== null) { + var _clone = { + expirationTime: Sync, + // This update is going to be committed so we never want uncommit it. + suspenseConfig: update.suspenseConfig, + tag: update.tag, + payload: update.payload, + callback: update.callback, + next: null + }; + newBaseQueueLast = newBaseQueueLast.next = _clone; + } // Mark the event time of this update as relevant to this render pass. + // TODO: This should ideally use the true event time of this update rather than + // its priority which is a derived and not reverseable value. + // TODO: We should skip this update if it was already committed but currently + // we have no way of detecting the difference between a committed and suspended + // update here. + + markRenderEventTimeAndConfig( + updateExpirationTime, + update.suspenseConfig + ); // Process this update. + + newState = getStateFromUpdate( + workInProgress, + queue, + update, + newState, + props, + instance + ); + var callback = update.callback; - if (_updateExpirationTime < renderExpirationTime) { - // This update does not have sufficient priority. Skip it. - if (newFirstCapturedUpdate === null) { - // This is the first skipped captured update. It will be the first - // update in the new list. - newFirstCapturedUpdate = update; // If this is the first update that was skipped, the current result is - // the new base state. + if (callback !== null) { + workInProgress.effectTag |= Callback; + var effects = queue.effects; - if (newFirstUpdate === null) { - newBaseState = resultState; + if (effects === null) { + queue.effects = [update]; + } else { + effects.push(update); + } + } } - } // Since this update will remain in the list, update the remaining - // expiration time. - - if (newExpirationTime < _updateExpirationTime) { - newExpirationTime = _updateExpirationTime; - } - } else { - // This update does have sufficient priority. Process it and compute - // a new result. - resultState = getStateFromUpdate( - workInProgress, - queue, - update, - resultState, - props, - instance - ); - var _callback = update.callback; - if (_callback !== null) { - workInProgress.effectTag |= Callback; // Set this to null, in case it was mutated during an aborted render. + update = update.next; - update.nextEffect = null; + if (update === null || update === first) { + pendingQueue = queue.shared.pending; - if (queue.lastCapturedEffect === null) { - queue.firstCapturedEffect = queue.lastCapturedEffect = update; - } else { - queue.lastCapturedEffect.nextEffect = update; - queue.lastCapturedEffect = update; + if (pendingQueue === null) { + break; + } else { + // An update was scheduled from inside a reducer. Add the new + // pending updates to the end of the list and keep processing. + update = baseQueue.next = pendingQueue.next; + pendingQueue.next = first; + queue.baseQueue = baseQueue = pendingQueue; + queue.shared.pending = null; + } } - } + } while (true); } - update = update.next; - } - - if (newFirstUpdate === null) { - queue.lastUpdate = null; - } + if (newBaseQueueLast === null) { + newBaseState = newState; + } else { + newBaseQueueLast.next = newBaseQueueFirst; + } - if (newFirstCapturedUpdate === null) { - queue.lastCapturedUpdate = null; - } else { - workInProgress.effectTag |= Callback; - } + queue.baseState = newBaseState; + queue.baseQueue = newBaseQueueLast; // Set the remaining expiration time to be whatever is remaining in the queue. + // This should be fine because the only two other things that contribute to + // expiration time are props and context. We're already in the middle of the + // begin phase by the time we start processing the queue, so we've already + // dealt with the props. Context in components that specify + // shouldComponentUpdate is tricky; but we'll have to account for + // that regardless. - if (newFirstUpdate === null && newFirstCapturedUpdate === null) { - // We processed every update, without skipping. That means the new base - // state is the same as the result state. - newBaseState = resultState; + markUnprocessedUpdateTime(newExpirationTime); + workInProgress.expirationTime = newExpirationTime; + workInProgress.memoizedState = newState; } - queue.baseState = newBaseState; - queue.firstUpdate = newFirstUpdate; - queue.firstCapturedUpdate = newFirstCapturedUpdate; // Set the remaining expiration time to be whatever is remaining in the queue. - // This should be fine because the only two other things that contribute to - // expiration time are props and context. We're already in the middle of the - // begin phase by the time we start processing the queue, so we've already - // dealt with the props. Context in components that specify - // shouldComponentUpdate is tricky; but we'll have to account for - // that regardless. - - markUnprocessedUpdateTime(newExpirationTime); - workInProgress.expirationTime = newExpirationTime; - workInProgress.memoizedState = resultState; - { currentlyProcessingQueue = null; } @@ -7684,36 +7534,20 @@ function commitUpdateQueue( instance, renderExpirationTime ) { - // If the finished render included captured updates, and there are still - // lower priority updates left over, we need to keep the captured updates - // in the queue so that they are rebased and not dropped once we process the - // queue again at the lower priority. - if (finishedQueue.firstCapturedUpdate !== null) { - // Join the captured update list to the end of the normal list. - if (finishedQueue.lastUpdate !== null) { - finishedQueue.lastUpdate.next = finishedQueue.firstCapturedUpdate; - finishedQueue.lastUpdate = finishedQueue.lastCapturedUpdate; - } // Clear the list of captured updates. - - finishedQueue.firstCapturedUpdate = finishedQueue.lastCapturedUpdate = null; - } // Commit the effects - - commitUpdateEffects(finishedQueue.firstEffect, instance); - finishedQueue.firstEffect = finishedQueue.lastEffect = null; - commitUpdateEffects(finishedQueue.firstCapturedEffect, instance); - finishedQueue.firstCapturedEffect = finishedQueue.lastCapturedEffect = null; -} - -function commitUpdateEffects(effect, instance) { - while (effect !== null) { - var callback = effect.callback; + // Commit the effects + var effects = finishedQueue.effects; + finishedQueue.effects = null; - if (callback !== null) { - effect.callback = null; - callCallback(callback, instance); - } + if (effects !== null) { + for (var i = 0; i < effects.length; i++) { + var effect = effects[i]; + var callback = effect.callback; - effect = effect.nextEffect; + if (callback !== null) { + effect.callback = null; + callCallback(callback, instance); + } + } } } @@ -7758,8 +7592,8 @@ var didWarnAboutInvalidateContextType; if (!didWarnOnInvalidCallback.has(key)) { didWarnOnInvalidCallback.add(key); - warningWithoutStack$1( - false, + + error( "%s(...): Expected the last optional `callback` argument to be a " + "function. Instead received: %s.", callerName, @@ -7774,8 +7608,8 @@ var didWarnAboutInvalidateContextType; if (!didWarnAboutUndefinedDerivedState.has(componentName)) { didWarnAboutUndefinedDerivedState.add(componentName); - warningWithoutStack$1( - false, + + error( "%s.getDerivedStateFromProps(): A valid state object (or null) must be returned. " + "You have returned undefined.", componentName @@ -7832,9 +7666,9 @@ function applyDerivedStateFromProps( workInProgress.memoizedState = memoizedState; // Once the update queue is empty, persist the derived state onto the // base state. - var updateQueue = workInProgress.updateQueue; - - if (updateQueue !== null && workInProgress.expirationTime === NoWork) { + if (workInProgress.expirationTime === NoWork) { + // Queue is always non-null for classes + var updateQueue = workInProgress.updateQueue; updateQueue.baseState = memoizedState; } } @@ -7933,14 +7767,13 @@ function checkShouldComponentUpdate( stopPhaseTimer(); { - !(shouldUpdate !== undefined) - ? warningWithoutStack$1( - false, - "%s.shouldComponentUpdate(): Returned undefined instead of a " + - "boolean value. Make sure to return true or false.", - getComponentName(ctor) || "Component" - ) - : void 0; + if (shouldUpdate === undefined) { + error( + "%s.shouldComponentUpdate(): Returned undefined instead of a " + + "boolean value. Make sure to return true or false.", + getComponentName(ctor) || "Component" + ); + } } return shouldUpdate; @@ -7964,15 +7797,13 @@ function checkClassInstance(workInProgress, ctor, newProps) { if (!renderPresent) { if (ctor.prototype && typeof ctor.prototype.render === "function") { - warningWithoutStack$1( - false, + error( "%s(...): No `render` method found on the returned component " + "instance: did you accidentally return an object from the constructor?", name ); } else { - warningWithoutStack$1( - false, + error( "%s(...): No `render` method found on the returned component " + "instance: you may have forgotten to define `render`.", name @@ -7980,54 +7811,50 @@ function checkClassInstance(workInProgress, ctor, newProps) { } } - var noGetInitialStateOnES6 = - !instance.getInitialState || - instance.getInitialState.isReactClassApproved || - instance.state; - !noGetInitialStateOnES6 - ? warningWithoutStack$1( - false, - "getInitialState was defined on %s, a plain JavaScript class. " + - "This is only supported for classes created using React.createClass. " + - "Did you mean to define a state property instead?", - name - ) - : void 0; - var noGetDefaultPropsOnES6 = - !instance.getDefaultProps || - instance.getDefaultProps.isReactClassApproved; - !noGetDefaultPropsOnES6 - ? warningWithoutStack$1( - false, - "getDefaultProps was defined on %s, a plain JavaScript class. " + - "This is only supported for classes created using React.createClass. " + - "Use a static property to define defaultProps instead.", - name - ) - : void 0; - var noInstancePropTypes = !instance.propTypes; - !noInstancePropTypes - ? warningWithoutStack$1( - false, - "propTypes was defined as an instance property on %s. Use a static " + - "property to define propTypes instead.", - name - ) - : void 0; - var noInstanceContextType = !instance.contextType; - !noInstanceContextType - ? warningWithoutStack$1( - false, - "contextType was defined as an instance property on %s. Use a static " + - "property to define contextType instead.", - name - ) - : void 0; + if ( + instance.getInitialState && + !instance.getInitialState.isReactClassApproved && + !instance.state + ) { + error( + "getInitialState was defined on %s, a plain JavaScript class. " + + "This is only supported for classes created using React.createClass. " + + "Did you mean to define a state property instead?", + name + ); + } + + if ( + instance.getDefaultProps && + !instance.getDefaultProps.isReactClassApproved + ) { + error( + "getDefaultProps was defined on %s, a plain JavaScript class. " + + "This is only supported for classes created using React.createClass. " + + "Use a static property to define defaultProps instead.", + name + ); + } + + if (instance.propTypes) { + error( + "propTypes was defined as an instance property on %s. Use a static " + + "property to define propTypes instead.", + name + ); + } + + if (instance.contextType) { + error( + "contextType was defined as an instance property on %s. Use a static " + + "property to define contextType instead.", + name + ); + } if (disableLegacyContext) { if (ctor.childContextTypes) { - warningWithoutStack$1( - false, + error( "%s uses the legacy childContextTypes API which is no longer supported. " + "Use React.createContext() instead.", name @@ -8035,23 +7862,20 @@ function checkClassInstance(workInProgress, ctor, newProps) { } if (ctor.contextTypes) { - warningWithoutStack$1( - false, + error( "%s uses the legacy contextTypes API which is no longer supported. " + "Use React.createContext() with static contextType instead.", name ); } } else { - var noInstanceContextTypes = !instance.contextTypes; - !noInstanceContextTypes - ? warningWithoutStack$1( - false, - "contextTypes was defined as an instance property on %s. Use a static " + - "property to define contextTypes instead.", - name - ) - : void 0; + if (instance.contextTypes) { + error( + "contextTypes was defined as an instance property on %s. Use a static " + + "property to define contextTypes instead.", + name + ); + } if ( ctor.contextType && @@ -8059,8 +7883,8 @@ function checkClassInstance(workInProgress, ctor, newProps) { !didWarnAboutContextTypeAndContextTypes.has(ctor) ) { didWarnAboutContextTypeAndContextTypes.add(ctor); - warningWithoutStack$1( - false, + + error( "%s declares both contextTypes and contextType static properties. " + "The legacy contextTypes property will be ignored.", name @@ -8068,26 +7892,22 @@ function checkClassInstance(workInProgress, ctor, newProps) { } } - var noComponentShouldUpdate = - typeof instance.componentShouldUpdate !== "function"; - !noComponentShouldUpdate - ? warningWithoutStack$1( - false, - "%s has a method called " + - "componentShouldUpdate(). Did you mean shouldComponentUpdate()? " + - "The name is phrased as a question because the function is " + - "expected to return a value.", - name - ) - : void 0; + if (typeof instance.componentShouldUpdate === "function") { + error( + "%s has a method called " + + "componentShouldUpdate(). Did you mean shouldComponentUpdate()? " + + "The name is phrased as a question because the function is " + + "expected to return a value.", + name + ); + } if ( ctor.prototype && ctor.prototype.isPureReactComponent && typeof instance.shouldComponentUpdate !== "undefined" ) { - warningWithoutStack$1( - false, + error( "%s has a method called shouldComponentUpdate(). " + "shouldComponentUpdate should not be used when extending React.PureComponent. " + "Please extend React.Component if shouldComponentUpdate is used.", @@ -8095,70 +7915,61 @@ function checkClassInstance(workInProgress, ctor, newProps) { ); } - var noComponentDidUnmount = - typeof instance.componentDidUnmount !== "function"; - !noComponentDidUnmount - ? warningWithoutStack$1( - false, - "%s has a method called " + - "componentDidUnmount(). But there is no such lifecycle method. " + - "Did you mean componentWillUnmount()?", - name - ) - : void 0; - var noComponentDidReceiveProps = - typeof instance.componentDidReceiveProps !== "function"; - !noComponentDidReceiveProps - ? warningWithoutStack$1( - false, - "%s has a method called " + - "componentDidReceiveProps(). But there is no such lifecycle method. " + - "If you meant to update the state in response to changing props, " + - "use componentWillReceiveProps(). If you meant to fetch data or " + - "run side-effects or mutations after React has updated the UI, use componentDidUpdate().", - name - ) - : void 0; - var noComponentWillRecieveProps = - typeof instance.componentWillRecieveProps !== "function"; - !noComponentWillRecieveProps - ? warningWithoutStack$1( - false, - "%s has a method called " + - "componentWillRecieveProps(). Did you mean componentWillReceiveProps()?", - name - ) - : void 0; - var noUnsafeComponentWillRecieveProps = - typeof instance.UNSAFE_componentWillRecieveProps !== "function"; - !noUnsafeComponentWillRecieveProps - ? warningWithoutStack$1( - false, - "%s has a method called " + - "UNSAFE_componentWillRecieveProps(). Did you mean UNSAFE_componentWillReceiveProps()?", - name - ) - : void 0; + if (typeof instance.componentDidUnmount === "function") { + error( + "%s has a method called " + + "componentDidUnmount(). But there is no such lifecycle method. " + + "Did you mean componentWillUnmount()?", + name + ); + } + + if (typeof instance.componentDidReceiveProps === "function") { + error( + "%s has a method called " + + "componentDidReceiveProps(). But there is no such lifecycle method. " + + "If you meant to update the state in response to changing props, " + + "use componentWillReceiveProps(). If you meant to fetch data or " + + "run side-effects or mutations after React has updated the UI, use componentDidUpdate().", + name + ); + } + + if (typeof instance.componentWillRecieveProps === "function") { + error( + "%s has a method called " + + "componentWillRecieveProps(). Did you mean componentWillReceiveProps()?", + name + ); + } + + if (typeof instance.UNSAFE_componentWillRecieveProps === "function") { + error( + "%s has a method called " + + "UNSAFE_componentWillRecieveProps(). Did you mean UNSAFE_componentWillReceiveProps()?", + name + ); + } + var hasMutatedProps = instance.props !== newProps; - !(instance.props === undefined || !hasMutatedProps) - ? warningWithoutStack$1( - false, - "%s(...): When calling super() in `%s`, make sure to pass " + - "up the same props that your component's constructor was passed.", - name, - name - ) - : void 0; - var noInstanceDefaultProps = !instance.defaultProps; - !noInstanceDefaultProps - ? warningWithoutStack$1( - false, - "Setting defaultProps as an instance property on %s is not supported and will be ignored." + - " Instead, define defaultProps as a static property on %s.", - name, - name - ) - : void 0; + + if (instance.props !== undefined && hasMutatedProps) { + error( + "%s(...): When calling super() in `%s`, make sure to pass " + + "up the same props that your component's constructor was passed.", + name, + name + ); + } + + if (instance.defaultProps) { + error( + "Setting defaultProps as an instance property on %s is not supported and will be ignored." + + " Instead, define defaultProps as a static property on %s.", + name, + name + ); + } if ( typeof instance.getSnapshotBeforeUpdate === "function" && @@ -8166,63 +7977,53 @@ function checkClassInstance(workInProgress, ctor, newProps) { !didWarnAboutGetSnapshotBeforeUpdateWithoutDidUpdate.has(ctor) ) { didWarnAboutGetSnapshotBeforeUpdateWithoutDidUpdate.add(ctor); - warningWithoutStack$1( - false, + + error( "%s: getSnapshotBeforeUpdate() should be used with componentDidUpdate(). " + "This component defines getSnapshotBeforeUpdate() only.", getComponentName(ctor) ); } - var noInstanceGetDerivedStateFromProps = - typeof instance.getDerivedStateFromProps !== "function"; - !noInstanceGetDerivedStateFromProps - ? warningWithoutStack$1( - false, - "%s: getDerivedStateFromProps() is defined as an instance method " + - "and will be ignored. Instead, declare it as a static method.", - name - ) - : void 0; - var noInstanceGetDerivedStateFromCatch = - typeof instance.getDerivedStateFromError !== "function"; - !noInstanceGetDerivedStateFromCatch - ? warningWithoutStack$1( - false, - "%s: getDerivedStateFromError() is defined as an instance method " + - "and will be ignored. Instead, declare it as a static method.", - name - ) - : void 0; - var noStaticGetSnapshotBeforeUpdate = - typeof ctor.getSnapshotBeforeUpdate !== "function"; - !noStaticGetSnapshotBeforeUpdate - ? warningWithoutStack$1( - false, - "%s: getSnapshotBeforeUpdate() is defined as a static method " + - "and will be ignored. Instead, declare it as an instance method.", - name - ) - : void 0; - var _state = instance.state; + if (typeof instance.getDerivedStateFromProps === "function") { + error( + "%s: getDerivedStateFromProps() is defined as an instance method " + + "and will be ignored. Instead, declare it as a static method.", + name + ); + } - if (_state && (typeof _state !== "object" || isArray$1(_state))) { - warningWithoutStack$1( - false, - "%s.state: must be set to an object or null", + if (typeof instance.getDerivedStateFromError === "function") { + error( + "%s: getDerivedStateFromError() is defined as an instance method " + + "and will be ignored. Instead, declare it as a static method.", + name + ); + } + + if (typeof ctor.getSnapshotBeforeUpdate === "function") { + error( + "%s: getSnapshotBeforeUpdate() is defined as a static method " + + "and will be ignored. Instead, declare it as an instance method.", name ); } - if (typeof instance.getChildContext === "function") { - !(typeof ctor.childContextTypes === "object") - ? warningWithoutStack$1( - false, - "%s.getChildContext(): childContextTypes must be defined in order to " + - "use getChildContext().", - name - ) - : void 0; + var _state = instance.state; + + if (_state && (typeof _state !== "object" || isArray$1(_state))) { + error("%s.state: must be set to an object or null", name); + } + + if ( + typeof instance.getChildContext === "function" && + typeof ctor.childContextTypes !== "object" + ) { + error( + "%s.getChildContext(): childContextTypes must be defined in order to " + + "use getChildContext().", + name + ); } } } @@ -8281,8 +8082,7 @@ function constructClassInstance( "}."; } - warningWithoutStack$1( - false, + error( "%s defines an invalid contextType. " + "contextType should point to the Context object returned by React.createContext().%s", getComponentName(ctor) || "Component", @@ -8326,8 +8126,8 @@ function constructClassInstance( if (!didWarnAboutUninitializedState.has(componentName)) { didWarnAboutUninitializedState.add(componentName); - warningWithoutStack$1( - false, + + error( "`%s` uses `getDerivedStateFromProps` but its initial state is " + "%s. This is not recommended. Instead, define the initial state by " + "assigning an object to `this.state` in the constructor of `%s`. " + @@ -8392,8 +8192,8 @@ function constructClassInstance( if (!didWarnAboutLegacyLifecyclesAndDerivedState.has(_componentName)) { didWarnAboutLegacyLifecyclesAndDerivedState.add(_componentName); - warningWithoutStack$1( - false, + + error( "Unsafe legacy lifecycles will not be called for components using new component APIs.\n\n" + "%s uses %s but also contains the following legacy lifecycles:%s%s%s\n\n" + "The above lifecycles should be removed. Learn more about this warning here:\n" + @@ -8435,8 +8235,7 @@ function callComponentWillMount(workInProgress, instance) { if (oldState !== instance.state) { { - warningWithoutStack$1( - false, + error( "%s.componentWillMount(): Assigning directly to this.state is " + "deprecated (except inside a component's " + "constructor). Use setState instead.", @@ -8473,8 +8272,8 @@ function callComponentWillReceiveProps( if (!didWarnAboutStateAssignmentForComponent.has(componentName)) { didWarnAboutStateAssignmentForComponent.add(componentName); - warningWithoutStack$1( - false, + + error( "%s.componentWillReceiveProps(): Assigning directly to " + "this.state is deprecated (except inside a component's " + "constructor). Use setState instead.", @@ -8501,6 +8300,7 @@ function mountClassInstance( instance.props = newProps; instance.state = workInProgress.memoizedState; instance.refs = emptyRefsObject; + initializeUpdateQueue(workInProgress); var contextType = ctor.contextType; if (typeof contextType === "object" && contextType !== null) { @@ -8518,8 +8318,8 @@ function mountClassInstance( if (!didWarnAboutDirectlyAssigningPropsToState.has(componentName)) { didWarnAboutDirectlyAssigningPropsToState.add(componentName); - warningWithoutStack$1( - false, + + error( "%s: It is not recommended to assign props directly to state " + "because updates to props won't be reflected in state. " + "In most cases, it is better to use props directly.", @@ -8543,19 +8343,8 @@ function mountClassInstance( } } - var updateQueue = workInProgress.updateQueue; - - if (updateQueue !== null) { - processUpdateQueue( - workInProgress, - updateQueue, - newProps, - instance, - renderExpirationTime - ); - instance.state = workInProgress.memoizedState; - } - + processUpdateQueue(workInProgress, newProps, instance, renderExpirationTime); + instance.state = workInProgress.memoizedState; var getDerivedStateFromProps = ctor.getDerivedStateFromProps; if (typeof getDerivedStateFromProps === "function") { @@ -8578,18 +8367,13 @@ function mountClassInstance( callComponentWillMount(workInProgress, instance); // If we had additional state updates during this life-cycle, let's // process them now. - updateQueue = workInProgress.updateQueue; - - if (updateQueue !== null) { - processUpdateQueue( - workInProgress, - updateQueue, - newProps, - instance, - renderExpirationTime - ); - instance.state = workInProgress.memoizedState; - } + processUpdateQueue( + workInProgress, + newProps, + instance, + renderExpirationTime + ); + instance.state = workInProgress.memoizedState; } if (typeof instance.componentDidMount === "function") { @@ -8648,18 +8432,8 @@ function resumeMountClassInstance( resetHasForceUpdateBeforeProcessing(); var oldState = workInProgress.memoizedState; var newState = (instance.state = oldState); - var updateQueue = workInProgress.updateQueue; - - if (updateQueue !== null) { - processUpdateQueue( - workInProgress, - updateQueue, - newProps, - instance, - renderExpirationTime - ); - newState = workInProgress.memoizedState; - } + processUpdateQueue(workInProgress, newProps, instance, renderExpirationTime); + newState = workInProgress.memoizedState; if ( oldProps === newProps && @@ -8749,6 +8523,7 @@ function updateClassInstance( renderExpirationTime ) { var instance = workInProgress.stateNode; + cloneUpdateQueue(current, workInProgress); var oldProps = workInProgress.memoizedProps; instance.props = workInProgress.type === workInProgress.elementType @@ -8792,18 +8567,8 @@ function updateClassInstance( resetHasForceUpdateBeforeProcessing(); var oldState = workInProgress.memoizedState; var newState = (instance.state = oldState); - var updateQueue = workInProgress.updateQueue; - - if (updateQueue !== null) { - processUpdateQueue( - workInProgress, - updateQueue, - newProps, - instance, - renderExpirationTime - ); - newState = workInProgress.memoizedState; - } + processUpdateQueue(workInProgress, newProps, instance, renderExpirationTime); + newState = workInProgress.memoizedState; if ( oldProps === newProps && @@ -8965,8 +8730,8 @@ var warnForMissingKey = function(child) {}; } ownerHasKeyUseWarning[currentComponentErrorInfo] = true; - warning$1( - false, + + error( "Each child in a list should have a unique " + '"key" prop. See https://fb.me/react-warning-keys for ' + "more information." @@ -8992,8 +8757,7 @@ function coerceRef(returnFiber, current$$1, element) { if (!didWarnAboutStringRefs[componentName]) { if (warnAboutStringRefs) { - warningWithoutStack$1( - false, + error( 'Component "%s" contains the string ref "%s". Support for string refs ' + "will be removed in a future major release. We recommend using " + "useRef() or createRef() instead. " + @@ -9004,8 +8768,7 @@ function coerceRef(returnFiber, current$$1, element) { getStackByFiberInDevAndProd(returnFiber) ); } else { - warningWithoutStack$1( - false, + error( 'A string ref, "%s", has been found within a strict mode tree. ' + "String refs are a source of potential bugs and should be avoided. " + "We recommend using useRef() or createRef() instead. " + @@ -9118,23 +8881,25 @@ function throwOnInvalidObjectType(returnFiber, newChild) { } function warnOnFunctionType() { - var currentComponentErrorInfo = - "Functions are not valid as a React child. This may happen if " + - "you return a Component instead of from render. " + - "Or maybe you meant to call this function rather than return it." + - getCurrentFiberStackInDev(); + { + var currentComponentErrorInfo = + "Functions are not valid as a React child. This may happen if " + + "you return a Component instead of from render. " + + "Or maybe you meant to call this function rather than return it." + + getCurrentFiberStackInDev(); - if (ownerHasFunctionTypeWarning[currentComponentErrorInfo]) { - return; - } + if (ownerHasFunctionTypeWarning[currentComponentErrorInfo]) { + return; + } - ownerHasFunctionTypeWarning[currentComponentErrorInfo] = true; - warning$1( - false, - "Functions are not valid as a React child. This may happen if " + - "you return a Component instead of from render. " + - "Or maybe you meant to call this function rather than return it." - ); + ownerHasFunctionTypeWarning[currentComponentErrorInfo] = true; + + error( + "Functions are not valid as a React child. This may happen if " + + "you return a Component instead of from render. " + + "Or maybe you meant to call this function rather than return it." + ); + } } // This wrapper function exists because I expect to clone the code in each path // to be able to optimize each path individually by branching early. This needs // a compiler or we can do it manually. Helpers that don't need this branching @@ -9272,33 +9037,51 @@ function ChildReconciler(shouldTrackSideEffects) { } function updateElement(returnFiber, current$$1, element, expirationTime) { - if ( - current$$1 !== null && - (current$$1.elementType === element.type || // Keep this check inline so it only runs on the false path: - isCompatibleFamilyForHotReloading(current$$1, element)) - ) { - // Move based on index - var existing = useFiber(current$$1, element.props, expirationTime); - existing.ref = coerceRef(returnFiber, current$$1, element); - existing.return = returnFiber; + if (current$$1 !== null) { + if ( + current$$1.elementType === element.type || // Keep this check inline so it only runs on the false path: + isCompatibleFamilyForHotReloading(current$$1, element) + ) { + // Move based on index + var existing = useFiber(current$$1, element.props, expirationTime); + existing.ref = coerceRef(returnFiber, current$$1, element); + existing.return = returnFiber; - { - existing._debugSource = element._source; - existing._debugOwner = element._owner; + { + existing._debugSource = element._source; + existing._debugOwner = element._owner; + } + + return existing; + } else if ( + enableChunksAPI && + current$$1.tag === Chunk && + element.type.$$typeof === REACT_CHUNK_TYPE && + element.type.render === current$$1.type.render + ) { + // Same as above but also update the .type field. + var _existing = useFiber(current$$1, element.props, expirationTime); + + _existing.return = returnFiber; + _existing.type = element.type; + + { + _existing._debugSource = element._source; + _existing._debugOwner = element._owner; + } + + return _existing; } + } // Insert - return existing; - } else { - // Insert - var created = createFiberFromElement( - element, - returnFiber.mode, - expirationTime - ); - created.ref = coerceRef(returnFiber, current$$1, element); - created.return = returnFiber; - return created; - } + var created = createFiberFromElement( + element, + returnFiber.mode, + expirationTime + ); + created.ref = coerceRef(returnFiber, current$$1, element); + created.return = returnFiber; + return created; } function updatePortal(returnFiber, current$$1, portal, expirationTime) { @@ -9616,8 +9399,7 @@ function ChildReconciler(shouldTrackSideEffects) { break; } - warning$1( - false, + error( "Encountered two children with the same key, `%s`. " + "Keys should be unique so that components maintain their identity " + "across updates. Non-unique keys may cause children to be " + @@ -9625,6 +9407,7 @@ function ChildReconciler(shouldTrackSideEffects) { "could change in a future version.", key ); + break; default: @@ -9830,28 +9613,28 @@ function ChildReconciler(shouldTrackSideEffects) { typeof Symbol === "function" && // $FlowFixMe Flow doesn't know about toStringTag newChildrenIterable[Symbol.toStringTag] === "Generator" ) { - !didWarnAboutGenerators - ? warning$1( - false, - "Using Generators as children is unsupported and will likely yield " + - "unexpected results because enumerating a generator mutates it. " + - "You may convert it to an array with `Array.from()` or the " + - "`[...spread]` operator before rendering. Keep in mind " + - "you might need to polyfill these features for older browsers." - ) - : void 0; + if (!didWarnAboutGenerators) { + error( + "Using Generators as children is unsupported and will likely yield " + + "unexpected results because enumerating a generator mutates it. " + + "You may convert it to an array with `Array.from()` or the " + + "`[...spread]` operator before rendering. Keep in mind " + + "you might need to polyfill these features for older browsers." + ); + } + didWarnAboutGenerators = true; } // Warn about using Maps as children if (newChildrenIterable.entries === iteratorFn) { - !didWarnAboutMaps - ? warning$1( - false, - "Using Maps as children is unsupported and will likely yield " + - "unexpected results. Convert it to a sequence/iterable of keyed " + - "ReactElements instead." - ) - : void 0; + if (!didWarnAboutMaps) { + error( + "Using Maps as children is unsupported and will likely yield " + + "unexpected results. Convert it to a sequence/iterable of keyed " + + "ReactElements instead." + ); + } + didWarnAboutMaps = true; } // First, validate keys. // We'll get a different iterator later for the main pass. @@ -10059,33 +9842,79 @@ function ChildReconciler(shouldTrackSideEffects) { // TODO: If key === null and child.key === null, then this only applies to // the first item in the list. if (child.key === key) { - if ( - child.tag === Fragment - ? element.type === REACT_FRAGMENT_TYPE - : child.elementType === element.type || // Keep this check inline so it only runs on the false path: + switch (child.tag) { + case Fragment: { + if (element.type === REACT_FRAGMENT_TYPE) { + deleteRemainingChildren(returnFiber, child.sibling); + var existing = useFiber( + child, + element.props.children, + expirationTime + ); + existing.return = returnFiber; + + { + existing._debugSource = element._source; + existing._debugOwner = element._owner; + } + + return existing; + } + + break; + } + + case Chunk: + if (enableChunksAPI) { + if ( + element.type.$$typeof === REACT_CHUNK_TYPE && + element.type.render === child.type.render + ) { + deleteRemainingChildren(returnFiber, child.sibling); + + var _existing2 = useFiber(child, element.props, expirationTime); + + _existing2.type = element.type; + _existing2.return = returnFiber; + + { + _existing2._debugSource = element._source; + _existing2._debugOwner = element._owner; + } + + return _existing2; + } + } + + // We intentionally fallthrough here if enableChunksAPI is not on. + // eslint-disable-next-lined no-fallthrough + + default: { + if ( + child.elementType === element.type || // Keep this check inline so it only runs on the false path: isCompatibleFamilyForHotReloading(child, element) - ) { - deleteRemainingChildren(returnFiber, child.sibling); - var existing = useFiber( - child, - element.type === REACT_FRAGMENT_TYPE - ? element.props.children - : element.props, - expirationTime - ); - existing.ref = coerceRef(returnFiber, child, element); - existing.return = returnFiber; + ) { + deleteRemainingChildren(returnFiber, child.sibling); - { - existing._debugSource = element._source; - existing._debugOwner = element._owner; + var _existing3 = useFiber(child, element.props, expirationTime); + + _existing3.ref = coerceRef(returnFiber, child, element); + _existing3.return = returnFiber; + + { + _existing3._debugSource = element._source; + _existing3._debugOwner = element._owner; + } + + return _existing3; + } + + break; } + } // Didn't match. - return existing; - } else { - deleteRemainingChildren(returnFiber, child); - break; - } + deleteRemainingChildren(returnFiber, child); + break; } else { deleteChild(returnFiber, child); } @@ -10580,7 +10409,7 @@ function mountEventResponder( } } - mountResponderInstance( + DEPRECATED_mountResponderInstance( responder, responderInstance, responderProps, @@ -10616,8 +10445,7 @@ function updateEventListener( if (visistedResponders.has(responder)) { // show warning { - warning$1( - false, + error( 'Duplicate event responder "%s" found in event listeners. ' + "Event listeners passed to elements cannot use the same event responder more than once.", responder.displayName @@ -10646,7 +10474,11 @@ function updateEventListener( } } -function updateEventListeners(listeners, fiber, rootContainerInstance) { +function updateDeprecatedEventListeners( + listeners, + fiber, + rootContainerInstance +) { var visistedResponders = new Set(); var dependencies = fiber.dependencies; @@ -10662,7 +10494,7 @@ function updateEventListeners(listeners, fiber, rootContainerInstance) { var respondersMap = dependencies.responders; if (respondersMap === null) { - respondersMap = new Map(); + dependencies.responders = respondersMap = new Map(); } if (isArray$2(listeners)) { @@ -10700,7 +10532,7 @@ function updateEventListeners(listeners, fiber, rootContainerInstance) { if (!visistedResponders.has(mountedResponder)) { var responderInstance = _respondersMap.get(mountedResponder); - unmountResponderInstance(responderInstance); + DEPRECATED_unmountResponderInstance(responderInstance); _respondersMap.delete(mountedResponder); } @@ -10708,7 +10540,7 @@ function updateEventListeners(listeners, fiber, rootContainerInstance) { } } } -function createResponderListener(responder, props) { +function createDeprecatedResponderListener(responder, props) { var eventResponderListener = { responder: responder, props: props @@ -10720,6 +10552,24 @@ function createResponderListener(responder, props) { return eventResponderListener; } +function unmountDeprecatedResponderListeners(fiber) { + var dependencies = fiber.dependencies; + + if (dependencies !== null) { + var respondersMap = dependencies.responders; + + if (respondersMap !== null) { + var responderInstances = Array.from(respondersMap.values()); + + for (var i = 0, length = responderInstances.length; i < length; i++) { + var responderInstance = responderInstances[i]; + DEPRECATED_unmountResponderInstance(responderInstance); + } + + dependencies.responders = null; + } + } +} var NoEffect$1 = /* */ @@ -10764,13 +10614,7 @@ var currentlyRenderingFiber$1 = null; // Hooks are stored as a linked list on th // work-in-progress fiber. var currentHook = null; -var nextCurrentHook = null; -var firstWorkInProgressHook = null; -var workInProgressHook = null; -var nextWorkInProgressHook = null; -var remainingExpirationTime = NoWork; -var componentUpdateQueue = null; -var sideEffectTag = 0; // Updates scheduled during render will trigger an immediate re-render at the +var workInProgressHook = null; // Updates scheduled during render will trigger an immediate re-render at the // end of the current pass. We can't store these updates on the normal queue, // because if the work is aborted, they should be discarded. Because this is // a relatively rare case, we also don't want to add an additional field to @@ -10828,8 +10672,7 @@ function checkDepsAreArrayDev(deps) { if (deps !== undefined && deps !== null && !Array.isArray(deps)) { // Verify deps, but only on mount to avoid extra checks. // It's unlikely their type would change as usually you define them inline. - warning$1( - false, + error( "%s received a final argument that is not an array (instead, received `%s`). When " + "specified, the final argument must be an array.", currentHookNameInDev, @@ -10865,8 +10708,7 @@ function warnOnHookMismatchInDev(currentHookName) { table += row; } - warning$1( - false, + error( "React has detected a change in the order of Hooks called by %s. " + "This will lead to bugs and errors if not fixed. " + "For more information, read the Rules of Hooks: https://fb.me/rules-of-hooks\n\n" + @@ -10900,8 +10742,7 @@ function areHookInputsEqual(nextDeps, prevDeps) { if (prevDeps === null) { { - warning$1( - false, + error( "%s received a final argument during this render, but not during " + "the previous render. Even though the final argument is optional, " + "its type cannot change between renders.", @@ -10916,8 +10757,7 @@ function areHookInputsEqual(nextDeps, prevDeps) { // Don't bother comparing lengths in prod because these arrays should be // passed inline. if (nextDeps.length !== prevDeps.length) { - warning$1( - false, + error( "The final argument passed to %s changed size between renders. The " + "order and size of this array must remain constant.\n\n" + "Previous: %s\n" + @@ -10945,12 +10785,11 @@ function renderWithHooks( workInProgress, Component, props, - refOrContext, + secondArg, nextRenderExpirationTime ) { renderExpirationTime$1 = nextRenderExpirationTime; currentlyRenderingFiber$1 = workInProgress; - nextCurrentHook = current !== null ? current.memoizedState : null; { hookTypesDev = current !== null ? current._debugHookTypes : null; @@ -10958,24 +10797,25 @@ function renderWithHooks( ignorePreviousDependencies = current !== null && current.type !== workInProgress.type; - } // The following should have already been reset + } + + workInProgress.memoizedState = null; + workInProgress.updateQueue = null; + workInProgress.expirationTime = NoWork; // The following should have already been reset // currentHook = null; // workInProgressHook = null; - // remainingExpirationTime = NoWork; - // componentUpdateQueue = null; // didScheduleRenderPhaseUpdate = false; // renderPhaseUpdates = null; // numberOfReRenders = 0; - // sideEffectTag = 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 nextCurrentHook === null. + // 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) - // Using nextCurrentHook to differentiate between mount/update only works if at least one stateful hook is used. + // Using memoizedState to differentiate between mount/update only works if at least one stateful hook is used. // Non-stateful hooks (e.g. context) don't get added to memoizedState, - // so nextCurrentHook would be null during updates and mounts. + // so memoizedState would be null during updates and mounts. { - if (nextCurrentHook !== null) { + if (current !== null && current.memoizedState !== null) { ReactCurrentDispatcher$1.current = HooksDispatcherOnUpdateInDEV; } else if (hookTypesDev !== null) { // This dispatcher handles an edge case where a component is updating, @@ -10989,7 +10829,7 @@ function renderWithHooks( } } - var children = Component(props, refOrContext); + var children = Component(props, secondArg); if (didScheduleRenderPhaseUpdate) { do { @@ -11002,11 +10842,9 @@ function renderWithHooks( ignorePreviousDependencies = false; } // Start over from the beginning of the list - nextCurrentHook = current !== null ? current.memoizedState : null; - nextWorkInProgressHook = firstWorkInProgressHook; currentHook = null; workInProgressHook = null; - componentUpdateQueue = null; + workInProgress.updateQueue = null; { // Also validate hook order for cascading updates. @@ -11014,7 +10852,7 @@ function renderWithHooks( } ReactCurrentDispatcher$1.current = HooksDispatcherOnUpdateInDEV; - children = Component(props, refOrContext); + children = Component(props, secondArg); } while (didScheduleRenderPhaseUpdate); renderPhaseUpdates = null; @@ -11023,14 +10861,9 @@ function renderWithHooks( // at the beginning of the render phase and there's no re-entrancy. ReactCurrentDispatcher$1.current = ContextOnlyDispatcher; - var renderedWork = currentlyRenderingFiber$1; - renderedWork.memoizedState = firstWorkInProgressHook; - renderedWork.expirationTime = remainingExpirationTime; - renderedWork.updateQueue = componentUpdateQueue; - renderedWork.effectTag |= sideEffectTag; { - renderedWork._debugHookTypes = hookTypesDev; + workInProgress._debugHookTypes = hookTypesDev; } // This check uses currentHook so that it works the same in DEV and prod bundles. // hookTypesDev could catch more cases (e.g. context) but only in DEV bundles. @@ -11038,20 +10871,13 @@ function renderWithHooks( renderExpirationTime$1 = NoWork; currentlyRenderingFiber$1 = null; currentHook = null; - nextCurrentHook = null; - firstWorkInProgressHook = null; workInProgressHook = null; - nextWorkInProgressHook = null; { currentHookNameInDev = null; hookTypesDev = null; hookTypesUpdateIndexDev = -1; - } - - remainingExpirationTime = NoWork; - componentUpdateQueue = null; - sideEffectTag = 0; // These were reset above + } // These were reset above // didScheduleRenderPhaseUpdate = false; // renderPhaseUpdates = null; // numberOfReRenders = 0; @@ -11082,10 +10908,7 @@ function resetHooks() { renderExpirationTime$1 = NoWork; currentlyRenderingFiber$1 = null; currentHook = null; - nextCurrentHook = null; - firstWorkInProgressHook = null; workInProgressHook = null; - nextWorkInProgressHook = null; { hookTypesDev = null; @@ -11093,9 +10916,6 @@ function resetHooks() { currentHookNameInDev = null; } - remainingExpirationTime = NoWork; - componentUpdateQueue = null; - sideEffectTag = 0; didScheduleRenderPhaseUpdate = false; renderPhaseUpdates = null; numberOfReRenders = 0; @@ -11105,14 +10925,14 @@ function mountWorkInProgressHook() { var hook = { memoizedState: null, baseState: null, + baseQueue: null, queue: null, - baseUpdate: null, next: null }; if (workInProgressHook === null) { // This is the first hook in the list - firstWorkInProgressHook = workInProgressHook = hook; + currentlyRenderingFiber$1.memoizedState = workInProgressHook = hook; } else { // Append to the end of the list workInProgressHook = workInProgressHook.next = hook; @@ -11127,12 +10947,33 @@ function updateWorkInProgressHook() { // clone, or a work-in-progress hook from a previous render pass that we can // use as a base. When we reach the end of the base list, we must switch to // the dispatcher used for mounts. + var nextCurrentHook; + + if (currentHook === null) { + var current = currentlyRenderingFiber$1.alternate; + + if (current !== null) { + nextCurrentHook = current.memoizedState; + } else { + nextCurrentHook = null; + } + } else { + nextCurrentHook = currentHook.next; + } + + var nextWorkInProgressHook; + + if (workInProgressHook === null) { + nextWorkInProgressHook = currentlyRenderingFiber$1.memoizedState; + } else { + nextWorkInProgressHook = workInProgressHook.next; + } + if (nextWorkInProgressHook !== null) { // There's already a work-in-progress. Reuse it. workInProgressHook = nextWorkInProgressHook; nextWorkInProgressHook = workInProgressHook.next; currentHook = nextCurrentHook; - nextCurrentHook = currentHook !== null ? currentHook.next : null; } else { // Clone from the current hook. if (!(nextCurrentHook !== null)) { @@ -11143,20 +10984,18 @@ function updateWorkInProgressHook() { var newHook = { memoizedState: currentHook.memoizedState, baseState: currentHook.baseState, + baseQueue: currentHook.baseQueue, queue: currentHook.queue, - baseUpdate: currentHook.baseUpdate, next: null }; if (workInProgressHook === null) { // This is the first hook in the list. - workInProgressHook = firstWorkInProgressHook = newHook; + currentlyRenderingFiber$1.memoizedState = workInProgressHook = newHook; } else { // Append to the end of the list. workInProgressHook = workInProgressHook.next = newHook; } - - nextCurrentHook = currentHook.next; } return workInProgressHook; @@ -11184,13 +11023,13 @@ function mountReducer(reducer, initialArg, init) { hook.memoizedState = hook.baseState = initialState; var queue = (hook.queue = { - last: null, + pending: null, dispatch: null, lastRenderedReducer: reducer, lastRenderedState: initialState }); var dispatch = (queue.dispatch = dispatchAction.bind( - null, // Flow doesn't know this is non-null, but we do. + null, currentlyRenderingFiber$1, queue )); @@ -11242,7 +11081,7 @@ function updateReducer(reducer, initialArg, init) { // TODO: Not sure if this is the desired semantics, but it's what we // do for gDSFP. I can't remember why. - if (hook.baseUpdate === queue.last) { + if (hook.baseQueue === null) { hook.baseState = newState; } @@ -11252,35 +11091,37 @@ function updateReducer(reducer, initialArg, init) { } return [hook.memoizedState, _dispatch]; - } // The last update in the entire queue + } - var last = queue.last; // The last update that is part of the base state. + var current = currentHook; // The last rebase update that is NOT part of the base state. - var baseUpdate = hook.baseUpdate; - var baseState = hook.baseState; // Find the first unprocessed update. + var baseQueue = current.baseQueue; // The last pending update that hasn't been processed yet. - var first; + var pendingQueue = queue.pending; - if (baseUpdate !== null) { - if (last !== null) { - // For the first update, the queue is a circular linked list where - // `queue.last.next = queue.first`. Once the first update commits, and - // the `baseUpdate` is no longer empty, we can unravel the list. - last.next = null; + if (pendingQueue !== null) { + // We have new updates that haven't been processed yet. + // We'll add them to the base queue. + if (baseQueue !== null) { + // Merge the pending queue and the base queue. + var baseFirst = baseQueue.next; + var pendingFirst = pendingQueue.next; + baseQueue.next = pendingFirst; + pendingQueue.next = baseFirst; } - first = baseUpdate.next; - } else { - first = last !== null ? last.next : null; + current.baseQueue = baseQueue = pendingQueue; + queue.pending = null; } - if (first !== null) { - var _newState = baseState; + if (baseQueue !== null) { + // We have a queue to process. + var first = baseQueue.next; + var _newState = current.baseState; var newBaseState = null; - var newBaseUpdate = null; - var prevUpdate = baseUpdate; + var newBaseQueueFirst = null; + var newBaseQueueLast = null; var _update = first; - var didSkip = false; do { var updateExpirationTime = _update.expirationTime; @@ -11289,24 +11130,46 @@ function updateReducer(reducer, initialArg, init) { // Priority is insufficient. Skip this update. If this is the first // skipped update, the previous update/state is the new base // update/state. - if (!didSkip) { - didSkip = true; - newBaseUpdate = prevUpdate; + var clone = { + expirationTime: _update.expirationTime, + suspenseConfig: _update.suspenseConfig, + action: _update.action, + eagerReducer: _update.eagerReducer, + eagerState: _update.eagerState, + next: null + }; + + if (newBaseQueueLast === null) { + newBaseQueueFirst = newBaseQueueLast = clone; newBaseState = _newState; + } else { + newBaseQueueLast = newBaseQueueLast.next = clone; } // Update the remaining priority in the queue. - if (updateExpirationTime > remainingExpirationTime) { - remainingExpirationTime = updateExpirationTime; - markUnprocessedUpdateTime(remainingExpirationTime); + if (updateExpirationTime > currentlyRenderingFiber$1.expirationTime) { + currentlyRenderingFiber$1.expirationTime = updateExpirationTime; + markUnprocessedUpdateTime(updateExpirationTime); } } else { // This update does have sufficient priority. - // Mark the event time of this update as relevant to this render pass. + if (newBaseQueueLast !== null) { + var _clone = { + expirationTime: Sync, + // This update is going to be committed so we never want uncommit it. + suspenseConfig: _update.suspenseConfig, + action: _update.action, + eagerReducer: _update.eagerReducer, + eagerState: _update.eagerState, + next: null + }; + newBaseQueueLast = newBaseQueueLast.next = _clone; + } // Mark the event time of this update as relevant to this render pass. // TODO: This should ideally use the true event time of this update rather than // its priority which is a derived and not reverseable value. // TODO: We should skip this update if it was already committed but currently // we have no way of detecting the difference between a committed and suspended // update here. + markRenderEventTimeAndConfig( updateExpirationTime, _update.suspenseConfig @@ -11322,13 +11185,13 @@ function updateReducer(reducer, initialArg, init) { } } - prevUpdate = _update; _update = _update.next; } while (_update !== null && _update !== first); - if (!didSkip) { - newBaseUpdate = prevUpdate; + if (newBaseQueueLast === null) { newBaseState = _newState; + } else { + newBaseQueueLast.next = newBaseQueueFirst; } // Mark that the fiber performed work, but only if the new state is // different from the current state. @@ -11337,8 +11200,8 @@ function updateReducer(reducer, initialArg, init) { } hook.memoizedState = _newState; - hook.baseUpdate = newBaseUpdate; hook.baseState = newBaseState; + hook.baseQueue = newBaseQueueLast; queue.lastRenderedState = _newState; } @@ -11355,13 +11218,13 @@ function mountState(initialState) { hook.memoizedState = hook.baseState = initialState; var queue = (hook.queue = { - last: null, + pending: null, dispatch: null, lastRenderedReducer: basicStateReducer, lastRenderedState: initialState }); var dispatch = (queue.dispatch = dispatchAction.bind( - null, // Flow doesn't know this is non-null, but we do. + null, currentlyRenderingFiber$1, queue )); @@ -11381,9 +11244,11 @@ function pushEffect(tag, create, destroy, deps) { // Circular next: null }; + var componentUpdateQueue = currentlyRenderingFiber$1.updateQueue; if (componentUpdateQueue === null) { componentUpdateQueue = createFunctionComponentUpdateQueue(); + currentlyRenderingFiber$1.updateQueue = componentUpdateQueue; componentUpdateQueue.lastEffect = effect.next = effect; } else { var lastEffect = componentUpdateQueue.lastEffect; @@ -11423,7 +11288,7 @@ function updateRef(initialValue) { function mountEffectImpl(fiberEffectTag, hookEffectTag, create, deps) { var hook = mountWorkInProgressHook(); var nextDeps = deps === undefined ? null : deps; - sideEffectTag |= fiberEffectTag; + currentlyRenderingFiber$1.effectTag |= fiberEffectTag; hook.memoizedState = pushEffect(hookEffectTag, create, undefined, nextDeps); } @@ -11446,7 +11311,7 @@ function updateEffectImpl(fiberEffectTag, hookEffectTag, create, deps) { } } - sideEffectTag |= fiberEffectTag; + currentlyRenderingFiber$1.effectTag |= fiberEffectTag; hook.memoizedState = pushEffect(hookEffectTag, create, destroy, nextDeps); } @@ -11504,14 +11369,13 @@ function imperativeHandleEffect(create, ref) { var refObject = ref; { - !refObject.hasOwnProperty("current") - ? warning$1( - false, - "Expected useImperativeHandle() first argument to either be a " + - "ref callback or React.createRef() object. Instead received: %s.", - "an object with keys {" + Object.keys(refObject).join(", ") + "}" - ) - : void 0; + if (!refObject.hasOwnProperty("current")) { + error( + "Expected useImperativeHandle() first argument to either be a " + + "ref callback or React.createRef() object. Instead received: %s.", + "an object with keys {" + Object.keys(refObject).join(", ") + "}" + ); + } } var _inst2 = create(); @@ -11525,14 +11389,13 @@ function imperativeHandleEffect(create, ref) { function mountImperativeHandle(ref, create, deps) { { - !(typeof create === "function") - ? warning$1( - false, - "Expected useImperativeHandle() second argument to be a function " + - "that creates a handle. Instead received: %s.", - create !== null ? typeof create : "null" - ) - : void 0; + if (typeof create !== "function") { + error( + "Expected useImperativeHandle() second argument to be a function " + + "that creates a handle. Instead received: %s.", + create !== null ? typeof create : "null" + ); + } } // TODO: If deps are provided, should we skip comparing the ref itself? var effectDeps = @@ -11547,14 +11410,13 @@ function mountImperativeHandle(ref, create, deps) { function updateImperativeHandle(ref, create, deps) { { - !(typeof create === "function") - ? warning$1( - false, - "Expected useImperativeHandle() second argument to be a function " + - "that creates a handle. Instead received: %s.", - create !== null ? typeof create : "null" - ) - : void 0; + if (typeof create !== "function") { + error( + "Expected useImperativeHandle() second argument to be a function " + + "that creates a handle. Instead received: %s.", + create !== null ? typeof create : "null" + ); + } } // TODO: If deps are provided, should we skip comparing the ref itself? var effectDeps = @@ -11637,17 +11499,14 @@ function mountDeferredValue(value, config) { mountEffect( function() { - Scheduler.unstable_next(function() { - var previousConfig = ReactCurrentBatchConfig$1.suspense; - ReactCurrentBatchConfig$1.suspense = - config === undefined ? null : config; + var previousConfig = ReactCurrentBatchConfig$1.suspense; + ReactCurrentBatchConfig$1.suspense = config === undefined ? null : config; - try { - setValue(value); - } finally { - ReactCurrentBatchConfig$1.suspense = previousConfig; - } - }); + try { + setValue(value); + } finally { + ReactCurrentBatchConfig$1.suspense = previousConfig; + } }, [value, config] ); @@ -11661,47 +11520,54 @@ function updateDeferredValue(value, config) { updateEffect( function() { - Scheduler.unstable_next(function() { - var previousConfig = ReactCurrentBatchConfig$1.suspense; - ReactCurrentBatchConfig$1.suspense = - config === undefined ? null : config; + var previousConfig = ReactCurrentBatchConfig$1.suspense; + ReactCurrentBatchConfig$1.suspense = config === undefined ? null : config; - try { - setValue(value); - } finally { - ReactCurrentBatchConfig$1.suspense = previousConfig; - } - }); + try { + setValue(value); + } finally { + ReactCurrentBatchConfig$1.suspense = previousConfig; + } }, [value, config] ); return prevValue; } +function startTransition(setPending, config, callback) { + var priorityLevel = getCurrentPriorityLevel(); + runWithPriority( + priorityLevel < UserBlockingPriority ? UserBlockingPriority : priorityLevel, + function() { + setPending(true); + } + ); + runWithPriority( + priorityLevel > NormalPriority ? NormalPriority : priorityLevel, + function() { + var previousConfig = ReactCurrentBatchConfig$1.suspense; + ReactCurrentBatchConfig$1.suspense = config === undefined ? null : config; + + try { + setPending(false); + callback(); + } finally { + ReactCurrentBatchConfig$1.suspense = previousConfig; + } + } + ); +} + function mountTransition(config) { var _mountState2 = mountState(false), isPending = _mountState2[0], setPending = _mountState2[1]; - var startTransition = mountCallback( - function(callback) { - setPending(true); - Scheduler.unstable_next(function() { - var previousConfig = ReactCurrentBatchConfig$1.suspense; - ReactCurrentBatchConfig$1.suspense = - config === undefined ? null : config; - - try { - setPending(false); - callback(); - } finally { - ReactCurrentBatchConfig$1.suspense = previousConfig; - } - }); - }, - [config, isPending] - ); - return [startTransition, isPending]; + var start = mountCallback(startTransition.bind(null, setPending, config), [ + setPending, + config + ]); + return [start, isPending]; } function updateTransition(config) { @@ -11709,25 +11575,11 @@ function updateTransition(config) { isPending = _updateState2[0], setPending = _updateState2[1]; - var startTransition = updateCallback( - function(callback) { - setPending(true); - Scheduler.unstable_next(function() { - var previousConfig = ReactCurrentBatchConfig$1.suspense; - ReactCurrentBatchConfig$1.suspense = - config === undefined ? null : config; - - try { - setPending(false); - callback(); - } finally { - ReactCurrentBatchConfig$1.suspense = previousConfig; - } - }); - }, - [config, isPending] - ); - return [startTransition, isPending]; + var start = updateCallback(startTransition.bind(null, setPending, config), [ + setPending, + config + ]); + return [start, isPending]; } function dispatchAction(fiber, queue, action) { @@ -11738,14 +11590,13 @@ function dispatchAction(fiber, queue, action) { } { - !(typeof arguments[3] !== "function") - ? warning$1( - false, - "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()." - ) - : void 0; + 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()." + ); + } } var alternate = fiber.alternate; @@ -11810,23 +11661,17 @@ function dispatchAction(fiber, queue, action) { _update2.priority = getCurrentPriorityLevel(); } // Append the update to the end of the list. - var last = queue.last; + var pending = queue.pending; - if (last === null) { + if (pending === null) { // This is the first update. Create a circular list. _update2.next = _update2; } else { - var first = last.next; - - if (first !== null) { - // Still circular. - _update2.next = first; - } - - last.next = _update2; + _update2.next = pending.next; + pending.next = _update2; } - queue.last = _update2; + queue.pending = _update2; if ( fiber.expirationTime === NoWork && @@ -11862,7 +11707,7 @@ function dispatchAction(fiber, queue, action) { // time the reducer has changed. return; } - } catch (error) { + } catch (error$$1) { // Suppress the error. It will throw again in the render phase. } finally { { @@ -11908,8 +11753,7 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null; { var warnInvalidContextAccess = function() { - warning$1( - false, + 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 " + @@ -11918,8 +11762,7 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null; }; var warnInvalidHookAccess = function() { - warning$1( - false, + error( "Do not call Hooks inside useEffect(...), useMemo(...), or other built-in Hooks. " + "You can only call Hooks at the top level of your React function. " + "For more information, see " + @@ -12010,7 +11853,7 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null; useResponder: function(responder, props) { currentHookNameInDev = "useResponder"; mountHookTypesDev(); - return createResponderListener(responder, props); + return createDeprecatedResponderListener(responder, props); }, useDeferredValue: function(value, config) { currentHookNameInDev = "useDeferredValue"; @@ -12101,7 +11944,7 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null; useResponder: function(responder, props) { currentHookNameInDev = "useResponder"; updateHookTypesDev(); - return createResponderListener(responder, props); + return createDeprecatedResponderListener(responder, props); }, useDeferredValue: function(value, config) { currentHookNameInDev = "useDeferredValue"; @@ -12192,7 +12035,7 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null; useResponder: function(responder, props) { currentHookNameInDev = "useResponder"; updateHookTypesDev(); - return createResponderListener(responder, props); + return createDeprecatedResponderListener(responder, props); }, useDeferredValue: function(value, config) { currentHookNameInDev = "useDeferredValue"; @@ -12295,7 +12138,7 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null; currentHookNameInDev = "useResponder"; warnInvalidHookAccess(); mountHookTypesDev(); - return createResponderListener(responder, props); + return createDeprecatedResponderListener(responder, props); }, useDeferredValue: function(value, config) { currentHookNameInDev = "useDeferredValue"; @@ -12400,7 +12243,7 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null; currentHookNameInDev = "useResponder"; warnInvalidHookAccess(); updateHookTypesDev(); - return createResponderListener(responder, props); + return createDeprecatedResponderListener(responder, props); }, useDeferredValue: function(value, config) { currentHookNameInDev = "useDeferredValue"; @@ -12480,12 +12323,11 @@ var isHydrating = false; function warnIfHydrating() { { - !!isHydrating - ? warning$1( - false, - "We should not be hydrating here. This is a bug in React. Please file a bug." - ) - : void 0; + if (isHydrating) { + error( + "We should not be hydrating here. This is a bug in React. Please file a bug." + ); + } } } @@ -13012,8 +12854,8 @@ function forceUnmountCurrentAndReconcile( renderExpirationTime ); // 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 their - // identity matches. + // the effect of remounting all children regardless of whether their + // identities match. workInProgress.child = reconcileChildFibers( workInProgress, @@ -13273,7 +13115,7 @@ function updateSimpleMemoComponent( if ( shallowEqual(prevProps, nextProps) && - current$$1.ref === workInProgress.ref && // Prevent bailout if the implementation changed due to hot reload: + current$$1.ref === workInProgress.ref && // Prevent bailout if the implementation changed due to hot reload. workInProgress.type === current$$1.type ) { didReceiveUpdate = false; @@ -13433,6 +13275,73 @@ function updateFunctionComponent( return workInProgress.child; } +function updateChunk( + current$$1, + workInProgress, + chunk, + nextProps, + renderExpirationTime +) { + // 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. + var render = chunk.render; + var data = chunk.query(); // The rest is a fork of updateFunctionComponent + + var nextChildren; + prepareToReadContext(workInProgress, renderExpirationTime); + + { + ReactCurrentOwner$3.current = workInProgress; + setCurrentPhase("render"); + nextChildren = renderWithHooks( + current$$1, + workInProgress, + render, + nextProps, + data, + renderExpirationTime + ); + + if ( + debugRenderPhaseSideEffectsForStrictMode && + workInProgress.mode & StrictMode + ) { + // Only double-render components with Hooks + if (workInProgress.memoizedState !== null) { + nextChildren = renderWithHooks( + current$$1, + workInProgress, + render, + nextProps, + data, + renderExpirationTime + ); + } + } + + setCurrentPhase(null); + } + + if (current$$1 !== null && !didReceiveUpdate) { + bailoutHooks(current$$1, workInProgress, renderExpirationTime); + return bailoutOnAlreadyFinishedWork( + current$$1, + workInProgress, + renderExpirationTime + ); + } // React DevTools reads this flag. + + workInProgress.effectTag |= PerformedWork; + reconcileChildren( + current$$1, + workInProgress, + nextChildren, + renderExpirationTime + ); + return workInProgress.child; +} + function updateClassComponent( current$$1, workInProgress, @@ -13475,9 +13384,9 @@ function updateClassComponent( if (instance === null) { if (current$$1 !== null) { - // An class component without an instance only mounts if it suspended - // inside a non- concurrent tree, in an inconsistent state. We want to - // tree it like a new mount, even though an empty version of it already + // 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$$1.alternate = null; workInProgress.alternate = null; // Since this is conceptually a new fiber, schedule a Placement effect @@ -13529,14 +13438,14 @@ function updateClassComponent( var inst = workInProgress.stateNode; if (inst.props !== nextProps) { - !didWarnAboutReassigningProps - ? warning$1( - false, - "It looks like %s is reassigning its own `this.props` while rendering. " + - "This is not supported and can lead to confusing bugs.", - getComponentName(workInProgress.type) || "a component" - ) - : void 0; + 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.", + getComponentName(workInProgress.type) || "a component" + ); + } + didWarnAboutReassigningProps = true; } } @@ -13578,7 +13487,7 @@ function finishClassComponent( didCaptureError && typeof Component.getDerivedStateFromError !== "function" ) { - // If we captured an error, but getDerivedStateFrom catch is not defined, + // 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. @@ -13657,7 +13566,7 @@ function updateHostRoot(current$$1, workInProgress, renderExpirationTime) { pushHostRootContext(workInProgress); var updateQueue = workInProgress.updateQueue; - if (!(updateQueue !== null)) { + if (!(current$$1 !== 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." ); @@ -13666,13 +13575,8 @@ function updateHostRoot(current$$1, workInProgress, renderExpirationTime) { var nextProps = workInProgress.pendingProps; var prevState = workInProgress.memoizedState; var prevChildren = prevState !== null ? prevState.element : null; - processUpdateQueue( - workInProgress, - updateQueue, - nextProps, - null, - renderExpirationTime - ); + cloneUpdateQueue(current$$1, workInProgress); + processUpdateQueue(workInProgress, nextProps, null, renderExpirationTime); var nextState = workInProgress.memoizedState; // Caution: React DevTools currently depends on this property // being called "element". @@ -13746,7 +13650,7 @@ function updateHostComponent(current$$1, workInProgress, renderExpirationTime) { if (isDirectTextChild) { // We special case a direct text child of a host node. This is a common // case. We won't handle it as a reified child. We will instead handle - // this in the host environment that also have access to this prop. That + // this in the host environment that also has access to this prop. That // avoids allocating another HostText fiber and traversing it. nextChildren = null; } else if (prevProps !== null && shouldSetTextContent(type, prevProps)) { @@ -13796,7 +13700,7 @@ function mountLazyComponent( renderExpirationTime ) { if (_current !== null) { - // An lazy component only mounts if it suspended inside a non- + // 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. @@ -13834,7 +13738,7 @@ function mountLazyComponent( resolvedProps, renderExpirationTime ); - break; + return child; } case ClassComponent: { @@ -13851,7 +13755,7 @@ function mountLazyComponent( resolvedProps, renderExpirationTime ); - break; + return child; } case ForwardRef: { @@ -13868,7 +13772,7 @@ function mountLazyComponent( resolvedProps, renderExpirationTime ); - break; + return child; } case MemoComponent: { @@ -13896,36 +13800,48 @@ function mountLazyComponent( updateExpirationTime, renderExpirationTime ); - break; + return child; } - default: { - 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 Error( - "Element type is invalid. Received a promise that resolves to: " + - Component + - ". Lazy element type must resolve to a class or function." + - hint + case Chunk: { + if (enableChunksAPI) { + // TODO: Resolve for Hot Reloading. + child = updateChunk( + null, + workInProgress, + Component, + props, + renderExpirationTime ); + return child; } + + break; } } - 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 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( @@ -14019,13 +13935,13 @@ function mountIndeterminateComponent( var componentName = getComponentName(Component) || "Unknown"; if (!didWarnAboutBadClass[componentName]) { - warningWithoutStack$1( - false, + 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 ); + didWarnAboutBadClass[componentName] = true; } } @@ -14057,8 +13973,7 @@ function mountIndeterminateComponent( var _componentName = getComponentName(Component) || "Unknown"; if (!didWarnAboutModulePatternComponent[_componentName]) { - warningWithoutStack$1( - false, + 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. " + @@ -14068,6 +13983,7 @@ function mountIndeterminateComponent( _componentName, _componentName ); + didWarnAboutModulePatternComponent[_componentName] = true; } } // Proceed under the assumption that this is a class instance @@ -14089,6 +14005,7 @@ function mountIndeterminateComponent( workInProgress.memoizedState = value.state !== null && value.state !== undefined ? value.state : null; + initializeUpdateQueue(workInProgress); var getDerivedStateFromProps = Component.getDerivedStateFromProps; if (typeof getDerivedStateFromProps === "function") { @@ -14116,8 +14033,7 @@ function mountIndeterminateComponent( { if (disableLegacyContext && Component.contextTypes) { - warningWithoutStack$1( - false, + error( "%s uses the legacy contextTypes API which is no longer supported. " + "Use React.createContext() with React.useContext() instead.", getComponentName(Component) || "Unknown" @@ -14153,86 +14069,87 @@ function mountIndeterminateComponent( } function validateFunctionComponentInDev(workInProgress, Component) { - if (Component) { - !!Component.childContextTypes - ? warningWithoutStack$1( - false, + { + if (Component) { + if (Component.childContextTypes) { + error( "%s(...): childContextTypes cannot be defined on a function component.", Component.displayName || Component.name || "Component" - ) - : void 0; - } + ); + } + } - if (workInProgress.ref !== null) { - var info = ""; - var ownerName = getCurrentFiberOwnerNameInDevOrNull(); + if (workInProgress.ref !== null) { + var info = ""; + var ownerName = getCurrentFiberOwnerNameInDevOrNull(); - if (ownerName) { - info += "\n\nCheck the render method of `" + ownerName + "`."; - } + if (ownerName) { + info += "\n\nCheck the render method of `" + ownerName + "`."; + } - var warningKey = ownerName || workInProgress._debugID || ""; - var debugSource = workInProgress._debugSource; + var warningKey = ownerName || workInProgress._debugID || ""; + var debugSource = workInProgress._debugSource; - if (debugSource) { - warningKey = debugSource.fileName + ":" + debugSource.lineNumber; - } + if (debugSource) { + warningKey = debugSource.fileName + ":" + debugSource.lineNumber; + } - if (!didWarnAboutFunctionRefs[warningKey]) { - didWarnAboutFunctionRefs[warningKey] = true; - warning$1( - false, - "Function components cannot be given refs. " + - "Attempts to access this ref will fail. " + - "Did you mean to use React.forwardRef()?%s", - info - ); + 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 + ); + } } - } - if ( - warnAboutDefaultPropsOnFunctionComponents && - Component.defaultProps !== undefined - ) { - var componentName = getComponentName(Component) || "Unknown"; - - if (!didWarnAboutDefaultPropsOnFunctionComponent[componentName]) { - warningWithoutStack$1( - false, - "%s: Support for defaultProps will be removed from function components " + - "in a future major release. Use JavaScript default parameters instead.", - componentName - ); - didWarnAboutDefaultPropsOnFunctionComponent[componentName] = true; + if ( + warnAboutDefaultPropsOnFunctionComponents && + Component.defaultProps !== undefined + ) { + var componentName = getComponentName(Component) || "Unknown"; + + if (!didWarnAboutDefaultPropsOnFunctionComponent[componentName]) { + error( + "%s: Support for defaultProps will be removed from function components " + + "in a future major release. Use JavaScript default parameters instead.", + componentName + ); + + didWarnAboutDefaultPropsOnFunctionComponent[componentName] = true; + } } - } - if (typeof Component.getDerivedStateFromProps === "function") { - var _componentName2 = getComponentName(Component) || "Unknown"; + if (typeof Component.getDerivedStateFromProps === "function") { + var _componentName2 = getComponentName(Component) || "Unknown"; - if (!didWarnAboutGetDerivedStateOnFunctionComponent[_componentName2]) { - warningWithoutStack$1( - false, - "%s: Function components do not support getDerivedStateFromProps.", - _componentName2 - ); - didWarnAboutGetDerivedStateOnFunctionComponent[_componentName2] = true; + if (!didWarnAboutGetDerivedStateOnFunctionComponent[_componentName2]) { + error( + "%s: Function components do not support getDerivedStateFromProps.", + _componentName2 + ); + + didWarnAboutGetDerivedStateOnFunctionComponent[_componentName2] = true; + } } - } - if ( - typeof Component.contextType === "object" && - Component.contextType !== null - ) { - var _componentName3 = getComponentName(Component) || "Unknown"; + if ( + typeof Component.contextType === "object" && + Component.contextType !== null + ) { + var _componentName3 = getComponentName(Component) || "Unknown"; - if (!didWarnAboutContextTypeOnFunctionComponent[_componentName3]) { - warningWithoutStack$1( - false, - "%s: Function components do not support contextType.", - _componentName3 - ); - didWarnAboutContextTypeOnFunctionComponent[_componentName3] = true; + if (!didWarnAboutContextTypeOnFunctionComponent[_componentName3]) { + error( + "%s: Function components do not support contextType.", + _componentName3 + ); + + didWarnAboutContextTypeOnFunctionComponent[_componentName3] = true; + } } } } @@ -14304,8 +14221,8 @@ function updateSuspenseComponent( if ("maxDuration" in nextProps) { if (!didWarnAboutMaxDuration) { didWarnAboutMaxDuration = true; - warning$1( - false, + + error( "maxDuration has been removed from React. " + "Remove the maxDuration prop." ); @@ -14677,7 +14594,7 @@ function updateSuspenseComponent( workInProgress.child = _primaryChildFragment3; return _fallbackChildFragment3; } else { - // Still haven't timed out. Continue rendering the children, like we + // Still haven't timed out. Continue rendering the children, like we // normally do. workInProgress.memoizedState = null; var _nextPrimaryChildren2 = nextProps.children; @@ -14723,8 +14640,7 @@ function mountDehydratedSuspenseComponent( // Instead, we'll leave the content in place and try to hydrate it later. if ((workInProgress.mode & BlockingMode) === NoMode) { { - warning$1( - false, + error( "Cannot hydrate Suspense in legacy mode. Switch from " + "ReactDOM.hydrate(element, container) to " + "ReactDOM.createBlockingRoot(container, { hydrate: true })" + @@ -14984,40 +14900,39 @@ function validateRevealOrder(revealOrder) { case "together": case "forwards": case "backwards": { - warning$1( - false, + error( '"%s" is not a valid value for revealOrder on . ' + 'Use lowercase "%s" instead.', revealOrder, revealOrder.toLowerCase() ); + break; } case "forward": case "backward": { - warning$1( - false, + 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: - warning$1( - false, + error( '"%s" is not a supported revealOrder on . ' + 'Did you mean "together", "forwards" or "backwards"?', revealOrder ); + break; } } else { - warning$1( - false, + error( "%s is not a supported value for revealOrder on . " + 'Did you mean "together", "forwards" or "backwards"?', revealOrder @@ -15032,16 +14947,16 @@ function validateTailOptions(tailMode, revealOrder) { if (tailMode !== undefined && !didWarnAboutTailOptions[tailMode]) { if (tailMode !== "collapsed" && tailMode !== "hidden") { didWarnAboutTailOptions[tailMode] = true; - warning$1( - false, + + 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; - warning$1( - false, + + error( ' is only valid if revealOrder is ' + '"forwards" or "backwards". ' + 'Did you mean to specify revealOrder="forwards"?', @@ -15059,8 +14974,8 @@ function validateSuspenseListNestedChild(childSlot, index) { if (isArray || isIterable) { var type = isArray ? "array" : "iterable"; - warning$1( - false, + + error( "A nested %s was passed to row #%s in . Wrap it in " + "an additional SuspenseList to configure its revealOrder: " + " ... " + @@ -15070,6 +14985,7 @@ function validateSuspenseListNestedChild(childSlot, index) { index, type ); + return false; } } @@ -15110,8 +15026,7 @@ function validateSuspenseListChildren(children, revealOrder) { } } } else { - warning$1( - false, + 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?", @@ -15137,6 +15052,7 @@ function initSuspenseListRenderState( workInProgress.memoizedState = { isBackwards: isBackwards, rendering: null, + renderingStartTime: 0, last: lastContentRow, tail: tail, tailExpiration: 0, @@ -15147,6 +15063,7 @@ function initSuspenseListRenderState( // 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.tailExpiration = 0; @@ -15419,8 +15336,8 @@ function updateContextConsumer( if (context !== context.Consumer) { if (!hasWarnedAboutUsingContextAsConsumer) { hasWarnedAboutUsingContextAsConsumer = true; - warning$1( - false, + + error( "Rendering directly is not supported and will be removed in " + "a future major release. Did you mean to render instead?" ); @@ -15435,15 +15352,14 @@ function updateContextConsumer( var render = newProps.children; { - !(typeof render === "function") - ? warningWithoutStack$1( - false, - "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." - ) - : void 0; + 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." + ); + } } prepareToReadContext(workInProgress, renderExpirationTime); @@ -16051,6 +15967,22 @@ function beginWork$1(current$$1, workInProgress, renderExpirationTime) { break; } + + case Chunk: { + if (enableChunksAPI) { + var chunk = workInProgress.type; + var props = workInProgress.pendingProps; + return updateChunk( + current$$1, + workInProgress, + chunk, + props, + renderExpirationTime + ); + } + + break; + } } { @@ -16735,6 +16667,8 @@ if (supportsMutation) { // This lets the parents know that at least one of their children has changed. markUpdate(workInProgress); + } else { + workInProgress.stateNode = current.stateNode; } }; } else { @@ -16833,14 +16767,16 @@ function completeWork(current, workInProgress, renderExpirationTime) { switch (workInProgress.tag) { case IndeterminateComponent: - break; - case LazyComponent: - break; - case SimpleMemoComponent: case FunctionComponent: - break; + case ForwardRef: + case Fragment: + case Mode: + case Profiler: + case ContextConsumer: + case MemoComponent: + return null; case ClassComponent: { var Component = workInProgress.type; @@ -16849,7 +16785,7 @@ function completeWork(current, workInProgress, renderExpirationTime) { popContext(workInProgress); } - break; + return null; } case HostRoot: { @@ -16875,7 +16811,7 @@ function completeWork(current, workInProgress, renderExpirationTime) { } updateHostContainer(workInProgress); - break; + return null; } case HostComponent: { @@ -16892,9 +16828,9 @@ function completeWork(current, workInProgress, renderExpirationTime) { rootContainerInstance ); - if (enableFlareAPI) { - var prevListeners = current.memoizedProps.listeners; - var nextListeners = newProps.listeners; + if (enableDeprecatedFlareAPI) { + var prevListeners = current.memoizedProps.DEPRECATED_flareListeners; + var nextListeners = newProps.DEPRECATED_flareListeners; if (prevListeners !== nextListeners) { markUpdate(workInProgress); @@ -16912,12 +16848,12 @@ function completeWork(current, workInProgress, renderExpirationTime) { ); } // This can happen when we abort work. - break; + return null; } 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 we want to add then top->down or + // or completeWork depending on whether we want to add them top->down or // bottom->up. Top->down is faster in IE11. var _wasHydrated = popHydrationState(workInProgress); @@ -16932,16 +16868,16 @@ function completeWork(current, workInProgress, renderExpirationTime) { currentHostContext ) ) { - // If changes to the hydrated node needs to be applied at the + // If changes to the hydrated node need to be applied at the // commit-phase we mark this as such. markUpdate(workInProgress); } - if (enableFlareAPI) { - var listeners = newProps.listeners; + if (enableDeprecatedFlareAPI) { + var listeners = newProps.DEPRECATED_flareListeners; if (listeners != null) { - updateEventListeners( + updateDeprecatedEventListeners( listeners, workInProgress, rootContainerInstance @@ -16960,11 +16896,11 @@ function completeWork(current, workInProgress, renderExpirationTime) { workInProgress.stateNode = instance; - if (enableFlareAPI) { - var _listeners = newProps.listeners; + if (enableDeprecatedFlareAPI) { + var _listeners = newProps.DEPRECATED_flareListeners; if (_listeners != null) { - updateEventListeners( + updateDeprecatedEventListeners( _listeners, workInProgress, rootContainerInstance @@ -16993,7 +16929,7 @@ function completeWork(current, workInProgress, renderExpirationTime) { } } - break; + return null; } case HostText: { @@ -17033,12 +16969,9 @@ function completeWork(current, workInProgress, renderExpirationTime) { } } - break; + return null; } - case ForwardRef: - break; - case SuspenseComponent: { popSuspenseContext(workInProgress); var nextState = workInProgress.memoizedState; @@ -17064,15 +16997,14 @@ function completeWork(current, workInProgress, renderExpirationTime) { } else { // We should never have been in a hydration state if we didn't have a current. // However, in some of those paths, we might have reentered a hydration state - // and then we might be inside a hydration state. In that case, we'll need to - // exit out of it. + // and then we might be inside a hydration state. In that case, we'll need to exit out of it. resetHydrationState(); if ((workInProgress.effectTag & DidCapture) === NoEffect) { // This boundary did not suspend so it's now hydrated and unsuspended. workInProgress.memoizedState = null; } // If nothing suspended, we need to schedule an effect to mark this boundary - // as having hydrated so events know that they're free be invoked. + // as having hydrated so events know that they're free to be invoked. // It's also a signal to replay events and the suspense callback. // If something suspended, schedule an effect to attach retry listeners. // So we might as well always mark this. @@ -17165,7 +17097,7 @@ function completeWork(current, workInProgress, renderExpirationTime) { // 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 proimse. This flag is also used to hide the + // retry listener to the promise. This flag is also used to hide the // primary children. workInProgress.effectTag |= Update; } @@ -17175,9 +17107,9 @@ function completeWork(current, workInProgress, renderExpirationTime) { // 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 proimse. This flag is also used to hide the + // 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 the + // *unhide* children that were previously hidden, so check if this // is currently timed out, too. workInProgress.effectTag |= Update; } @@ -17192,33 +17124,18 @@ function completeWork(current, workInProgress, renderExpirationTime) { workInProgress.effectTag |= Update; } - break; + return null; } - case Fragment: - break; - - case Mode: - break; - - case Profiler: - break; - case HostPortal: popHostContainer(workInProgress); updateHostContainer(workInProgress); - break; + return null; case ContextProvider: // Pop provider fiber popProvider(workInProgress); - break; - - case ContextConsumer: - break; - - case MemoComponent: - break; + return null; case IncompleteClassComponent: { // Same as class component case. I put it down here so that the tags are @@ -17229,7 +17146,7 @@ function completeWork(current, workInProgress, renderExpirationTime) { popContext(workInProgress); } - break; + return null; } case SuspenseListComponent: { @@ -17237,9 +17154,9 @@ function completeWork(current, workInProgress, renderExpirationTime) { var renderState = workInProgress.memoizedState; if (renderState === null) { - // We're running in the default, "independent" mode. We don't do anything - // in this mode. - break; + // We're running in the default, "independent" mode. + // We don't do anything in this mode. + return null; } var didSuspendAlready = @@ -17355,7 +17272,10 @@ function completeWork(current, workInProgress, renderExpirationTime) { return null; } } else if ( - now() > renderState.tailExpiration && + // The time it took to render last row is greater than time until + // the expiration. + now() * 2 - renderState.renderingStartTime > + renderState.tailExpiration && renderExpirationTime > Never ) { // We have now passed our CPU deadline and we'll just give up further @@ -17405,13 +17325,19 @@ function completeWork(current, workInProgress, renderExpirationTime) { // Heuristic for how long we're willing to spend rendering rows // until we just give up and show what we have so far. var TAIL_EXPIRATION_TIMEOUT_MS = 500; - renderState.tailExpiration = now() + TAIL_EXPIRATION_TIMEOUT_MS; + renderState.tailExpiration = now() + TAIL_EXPIRATION_TIMEOUT_MS; // TODO: This is meant to mimic the train model or JND but this + // is a per component value. It should really be since the start + // of the total render or last commit. Consider using something like + // globalMostRecentFallbackTime. That doesn't account for being + // suspended for part of the time or when it's a new render. + // It should probably use a global start time value instead. } // Pop a row. var next = renderState.tail; renderState.rendering = next; renderState.tail = next.sibling; renderState.lastEffect = workInProgress.lastEffect; + 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. @@ -17432,7 +17358,7 @@ function completeWork(current, workInProgress, renderExpirationTime) { return next; } - break; + return null; } case FundamentalComponent: { @@ -17487,6 +17413,8 @@ function completeWork(current, workInProgress, renderExpirationTime) { markUpdate(workInProgress); } } + + return null; } break; @@ -17503,13 +17431,13 @@ function completeWork(current, workInProgress, renderExpirationTime) { workInProgress.stateNode = scopeInstance; scopeInstance.methods = createScopeMethods(_type3, scopeInstance); - if (enableFlareAPI) { - var _listeners2 = newProps.listeners; + if (enableDeprecatedFlareAPI) { + var _listeners2 = newProps.DEPRECATED_flareListeners; if (_listeners2 != null) { var _rootContainerInstance2 = getRootHostContainer(); - updateEventListeners( + updateDeprecatedEventListeners( _listeners2, workInProgress, _rootContainerInstance2 @@ -17522,9 +17450,10 @@ function completeWork(current, workInProgress, renderExpirationTime) { markUpdate(workInProgress); } } else { - if (enableFlareAPI) { - var _prevListeners = current.memoizedProps.listeners; - var _nextListeners = newProps.listeners; + if (enableDeprecatedFlareAPI) { + var _prevListeners = + current.memoizedProps.DEPRECATED_flareListeners; + var _nextListeners = newProps.DEPRECATED_flareListeners; if ( _prevListeners !== _nextListeners || @@ -17542,21 +17471,28 @@ function completeWork(current, workInProgress, renderExpirationTime) { markRef$1(workInProgress); } } + + return null; } break; } - default: { - throw Error( - "Unknown unit of work tag (" + - workInProgress.tag + - "). This error is likely caused by a bug in React. Please file an issue." - ); - } + case Chunk: + if (enableChunksAPI) { + return null; + } + + break; } - 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." + ); + } } function unwindWork(workInProgress, renderExpirationTime) { @@ -17749,7 +17685,8 @@ function logCapturedError(capturedError) { // However, the browser would have silenced the original error // so we'll print it first, and then print the stack addendum. - console.error(error); // For a more detailed description of this block, see: + console["error"](error); // Don't transform to our wrapper + // For a more detailed description of this block, see: // https://github.com/facebook/react/pull/13384 } @@ -17786,7 +17723,7 @@ function logCapturedError(capturedError) { // has already printed it. Even if the application swallows the error, it is still // displayed by the browser thanks to the DEV-only fake event trick in ReactErrorUtils. - console.error(combinedMessage); + console["error"](combinedMessage); // Don't transform to our wrapper } } @@ -17884,8 +17821,8 @@ function safelyCallDestroy(current$$1, destroy) { invokeGuardedCallback(null, destroy, null); if (hasCaughtError()) { - var error = clearCaughtError(); - captureCommitPhaseError(current$$1, error); + var error$$1 = clearCaughtError(); + captureCommitPhaseError(current$$1, error$$1); } } } @@ -17894,7 +17831,8 @@ function commitBeforeMutationLifeCycles(current$$1, finishedWork) { switch (finishedWork.tag) { case FunctionComponent: case ForwardRef: - case SimpleMemoComponent: { + case SimpleMemoComponent: + case Chunk: { commitHookEffectList(UnmountSnapshot, NoEffect$1, finishedWork); return; } @@ -17914,28 +17852,27 @@ function commitBeforeMutationLifeCycles(current$$1, finishedWork) { finishedWork.type === finishedWork.elementType && !didWarnAboutReassigningProps ) { - !(instance.props === finishedWork.memoizedProps) - ? warning$1( - false, - "Expected %s props to match memoized props before " + - "getSnapshotBeforeUpdate. " + - "This might either be because of a bug in React, or because " + - "a component reassigns its own `this.props`. " + - "Please file an issue.", - getComponentName(finishedWork.type) || "instance" - ) - : void 0; - !(instance.state === finishedWork.memoizedState) - ? warning$1( - false, - "Expected %s state to match memoized state before " + - "getSnapshotBeforeUpdate. " + - "This might either be because of a bug in React, or because " + - "a component reassigns its own `this.props`. " + - "Please file an issue.", - getComponentName(finishedWork.type) || "instance" - ) - : void 0; + if (instance.props !== finishedWork.memoizedProps) { + error( + "Expected %s props to match memoized props before " + + "getSnapshotBeforeUpdate. " + + "This might either be because of a bug in React, or because " + + "a component reassigns its own `this.props`. " + + "Please file an issue.", + getComponentName(finishedWork.type) || "instance" + ); + } + + if (instance.state !== finishedWork.memoizedState) { + error( + "Expected %s state to match memoized state before " + + "getSnapshotBeforeUpdate. " + + "This might either be because of a bug in React, or because " + + "a component reassigns its own `this.props`. " + + "Please file an issue.", + getComponentName(finishedWork.type) || "instance" + ); + } } } @@ -17951,8 +17888,8 @@ function commitBeforeMutationLifeCycles(current$$1, finishedWork) { if (snapshot === undefined && !didWarnSet.has(finishedWork.type)) { didWarnSet.add(finishedWork.type); - warningWithoutStack$1( - false, + + error( "%s.getSnapshotBeforeUpdate(): A snapshot value (or null) " + "must be returned. You have returned undefined.", getComponentName(finishedWork.type) @@ -17975,14 +17912,12 @@ function commitBeforeMutationLifeCycles(current$$1, finishedWork) { case IncompleteClassComponent: // Nothing to do for these component types return; + } - 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 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." + ); } } @@ -18038,8 +17973,7 @@ function commitHookEffectList(unmountTag, mountTag, finishedWork) { addendum = " You returned: " + _destroy; } - warningWithoutStack$1( - false, + error( "An effect function must not return anything besides a function, " + "which is used for clean-up.%s%s", addendum, @@ -18059,7 +17993,8 @@ function commitPassiveHookEffects(finishedWork) { switch (finishedWork.tag) { case FunctionComponent: case ForwardRef: - case SimpleMemoComponent: { + case SimpleMemoComponent: + case Chunk: { commitHookEffectList(UnmountPassive, NoEffect$1, finishedWork); commitHookEffectList(NoEffect$1, MountPassive, finishedWork); break; @@ -18080,9 +18015,10 @@ function commitLifeCycles( switch (finishedWork.tag) { case FunctionComponent: case ForwardRef: - case SimpleMemoComponent: { + case SimpleMemoComponent: + case Chunk: { commitHookEffectList(UnmountLayout, MountLayout, finishedWork); - break; + return; } case ClassComponent: { @@ -18099,28 +18035,27 @@ function commitLifeCycles( finishedWork.type === finishedWork.elementType && !didWarnAboutReassigningProps ) { - !(instance.props === finishedWork.memoizedProps) - ? warning$1( - false, - "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.", - getComponentName(finishedWork.type) || "instance" - ) - : void 0; - !(instance.state === finishedWork.memoizedState) - ? warning$1( - false, - "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.props`. " + - "Please file an issue.", - getComponentName(finishedWork.type) || "instance" - ) - : void 0; + 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.", + getComponentName(finishedWork.type) || "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.props`. " + + "Please file an issue.", + getComponentName(finishedWork.type) || "instance" + ); + } } } @@ -18144,28 +18079,27 @@ function commitLifeCycles( finishedWork.type === finishedWork.elementType && !didWarnAboutReassigningProps ) { - !(instance.props === finishedWork.memoizedProps) - ? warning$1( - false, - "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.", - getComponentName(finishedWork.type) || "instance" - ) - : void 0; - !(instance.state === finishedWork.memoizedState) - ? warning$1( - false, - "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.props`. " + - "Please file an issue.", - getComponentName(finishedWork.type) || "instance" - ) - : void 0; + 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.", + getComponentName(finishedWork.type) || "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.props`. " + + "Please file an issue.", + getComponentName(finishedWork.type) || "instance" + ); + } } } @@ -18186,28 +18120,27 @@ function commitLifeCycles( finishedWork.type === finishedWork.elementType && !didWarnAboutReassigningProps ) { - !(instance.props === finishedWork.memoizedProps) - ? warning$1( - false, - "Expected %s props to match memoized props before " + - "processing the update queue. " + - "This might either be because of a bug in React, or because " + - "a component reassigns its own `this.props`. " + - "Please file an issue.", - getComponentName(finishedWork.type) || "instance" - ) - : void 0; - !(instance.state === finishedWork.memoizedState) - ? warning$1( - false, - "Expected %s state to match memoized state before " + - "processing the update queue. " + - "This might either be because of a bug in React, or because " + - "a component reassigns its own `this.props`. " + - "Please file an issue.", - getComponentName(finishedWork.type) || "instance" - ) - : void 0; + if (instance.props !== finishedWork.memoizedProps) { + error( + "Expected %s props to match memoized props before " + + "processing the update queue. " + + "This might either be because of a bug in React, or because " + + "a component reassigns its own `this.props`. " + + "Please file an issue.", + getComponentName(finishedWork.type) || "instance" + ); + } + + if (instance.state !== finishedWork.memoizedState) { + error( + "Expected %s state to match memoized state before " + + "processing the update queue. " + + "This might either be because of a bug in React, or because " + + "a component reassigns its own `this.props`. " + + "Please file an issue.", + getComponentName(finishedWork.type) || "instance" + ); + } } } // We could update instance props and state here, // but instead we rely on them being set during last render. @@ -18318,14 +18251,12 @@ function commitLifeCycles( case FundamentalComponent: case ScopeComponent: return; + } - 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 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." + ); } } @@ -18412,8 +18343,7 @@ function commitAttachRef(finishedWork) { } else { { if (!ref.hasOwnProperty("current")) { - warningWithoutStack$1( - false, + error( "Unexpected ref object provided for %s. " + "Use either a ref-setter function or React.createRef().%s", getComponentName(finishedWork.type), @@ -18448,7 +18378,8 @@ function commitUnmount(finishedRoot, current$$1, renderPriorityLevel) { case FunctionComponent: case ForwardRef: case MemoComponent: - case SimpleMemoComponent: { + case SimpleMemoComponent: + case Chunk: { var updateQueue = current$$1.updateQueue; if (updateQueue !== null) { @@ -18488,7 +18419,7 @@ function commitUnmount(finishedRoot, current$$1, renderPriorityLevel) { } } - break; + return; } case ClassComponent: { @@ -18503,27 +18434,9 @@ function commitUnmount(finishedRoot, current$$1, renderPriorityLevel) { } case HostComponent: { - if (enableFlareAPI) { - var dependencies = current$$1.dependencies; - - if (dependencies !== null) { - var respondersMap = dependencies.responders; - - if (respondersMap !== null) { - var responderInstances = Array.from(respondersMap.values()); - - for ( - var i = 0, length = responderInstances.length; - i < length; - i++ - ) { - var responderInstance = responderInstances[i]; - unmountResponderInstance(responderInstance); - } - - dependencies.responders = null; - } - } + if (enableDeprecatedFlareAPI) { + unmountDeprecatedResponderListeners(current$$1); + beforeRemoveInstance(current$$1.stateNode); } safelyDetachRef(current$$1); @@ -18573,9 +18486,15 @@ function commitUnmount(finishedRoot, current$$1, renderPriorityLevel) { } case ScopeComponent: { + if (enableDeprecatedFlareAPI) { + unmountDeprecatedResponderListeners(current$$1); + } + if (enableScopeAPI) { safelyDetachRef(current$$1); } + + return; } } } @@ -18636,6 +18555,7 @@ function detachFiber(current$$1) { current$$1.lastEffect = null; current$$1.pendingProps = null; current$$1.memoizedProps = null; + current$$1.stateNode = null; if (alternate !== null) { detachFiber(alternate); @@ -18674,14 +18594,12 @@ function commitContainer(finishedWork) { replaceContainerChildren(containerInfo, pendingChildren); return; } + } - 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 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." + ); } } @@ -19015,7 +18933,8 @@ function commitWork(current$$1, finishedWork) { case FunctionComponent: case ForwardRef: case MemoComponent: - case SimpleMemoComponent: { + case SimpleMemoComponent: + case Chunk: { // Note: We currently never use MountMutation, but useLayout uses // UnmountMutation. commitHookEffectList(UnmountMutation, MountMutation, finishedWork); @@ -19060,7 +18979,8 @@ function commitWork(current$$1, finishedWork) { case FunctionComponent: case ForwardRef: case MemoComponent: - case SimpleMemoComponent: { + case SimpleMemoComponent: + case Chunk: { // Note: We currently never use MountMutation, but useLayout uses // UnmountMutation. commitHookEffectList(UnmountMutation, MountMutation, finishedWork); @@ -19098,12 +19018,12 @@ function commitWork(current$$1, finishedWork) { ); } - if (enableFlareAPI) { - var prevListeners = oldProps.listeners; - var nextListeners = newProps.listeners; + if (enableDeprecatedFlareAPI) { + var prevListeners = oldProps.DEPRECATED_flareListeners; + var nextListeners = newProps.DEPRECATED_flareListeners; if (prevListeners !== nextListeners) { - updateEventListeners(nextListeners, finishedWork, null); + updateDeprecatedEventListeners(nextListeners, finishedWork, null); } } } @@ -19165,9 +19085,10 @@ function commitWork(current$$1, finishedWork) { if (enableFundamentalAPI) { var fundamentalInstance = finishedWork.stateNode; updateFundamentalComponent(fundamentalInstance); + return; } - return; + break; } case ScopeComponent: { @@ -19175,31 +19096,31 @@ function commitWork(current$$1, finishedWork) { var scopeInstance = finishedWork.stateNode; scopeInstance.fiber = finishedWork; - if (enableFlareAPI) { + if (enableDeprecatedFlareAPI) { var _newProps = finishedWork.memoizedProps; var _oldProps = current$$1 !== null ? current$$1.memoizedProps : _newProps; - var _prevListeners = _oldProps.listeners; - var _nextListeners = _newProps.listeners; + var _prevListeners = _oldProps.DEPRECATED_flareListeners; + var _nextListeners = _newProps.DEPRECATED_flareListeners; - if (_prevListeners !== _nextListeners) { - updateEventListeners(_nextListeners, finishedWork, null); + if (_prevListeners !== _nextListeners || current$$1 === null) { + updateDeprecatedEventListeners(_nextListeners, finishedWork, null); } } + + return; } - return; + 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 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." + ); } } @@ -19231,7 +19152,7 @@ function commitSuspenseComponent(finishedWork) { } } else { if (suspenseCallback !== undefined) { - warning$1(false, "Unexpected type for suspenseCallback."); + error("Unexpected type for suspenseCallback."); } } } @@ -19324,10 +19245,10 @@ function createRootErrorUpdate(fiber, errorInfo, expirationTime) { update.payload = { element: null }; - var error = errorInfo.value; + var error$$1 = errorInfo.value; update.callback = function() { - onUncaughtError(error); + onUncaughtError(error$$1); logError(fiber, errorInfo); }; @@ -19340,11 +19261,11 @@ function createClassErrorUpdate(fiber, errorInfo, expirationTime) { var getDerivedStateFromError = fiber.type.getDerivedStateFromError; if (typeof getDerivedStateFromError === "function") { - var error = errorInfo.value; + var error$$1 = errorInfo.value; update.payload = function() { logError(fiber, errorInfo); - return getDerivedStateFromError(error); + return getDerivedStateFromError(error$$1); }; } @@ -19367,9 +19288,9 @@ function createClassErrorUpdate(fiber, errorInfo, expirationTime) { logError(fiber, errorInfo); } - var error = errorInfo.value; + var error$$1 = errorInfo.value; var stack = errorInfo.stack; - this.componentDidCatch(error, { + this.componentDidCatch(error$$1, { componentStack: stack !== null ? stack : "" }); @@ -19378,14 +19299,13 @@ function createClassErrorUpdate(fiber, errorInfo, expirationTime) { // If componentDidCatch is the only error boundary method defined, // then it needs to call setState to recover from errors. // If no state update is scheduled then the boundary will swallow the error. - !(fiber.expirationTime === Sync) - ? warningWithoutStack$1( - false, - "%s: Error boundaries should implement getDerivedStateFromError(). " + - "In that method, return a state update to display an error message or fallback UI.", - getComponentName(fiber.type) || "Unknown" - ) - : void 0; + if (fiber.expirationTime !== Sync) { + error( + "%s: Error boundaries should implement getDerivedStateFromError(). " + + "In that method, return a state update to display an error message or fallback UI.", + getComponentName(fiber.type) || "Unknown" + ); + } } } }; @@ -19450,6 +19370,20 @@ function throwException( ) { // This is a thenable. var thenable = value; + + if ((sourceFiber.mode & BlockingMode) === NoMode) { + // Reset the memoizedState to what it was before we attempted + // to render it. + var currentSource = sourceFiber.alternate; + + if (currentSource) { + sourceFiber.memoizedState = currentSource.memoizedState; + sourceFiber.expirationTime = currentSource.expirationTime; + } else { + sourceFiber.memoizedState = null; + } + } + checkForWrongSuspensePriorityInDEV(sourceFiber); var hasInvisibleParentBoundary = hasSuspenseContext( suspenseStackCursor.current, @@ -19975,9 +19909,21 @@ function getNextRootExpirationTimeToWorkOn(root) { var lastPingedTime = root.lastPingedTime; var nextKnownPendingLevel = root.nextKnownPendingLevel; - return lastPingedTime > nextKnownPendingLevel - ? lastPingedTime - : nextKnownPendingLevel; + var nextLevel = + lastPingedTime > nextKnownPendingLevel + ? lastPingedTime + : nextKnownPendingLevel; + + if ( + enableTrainModelFix && + nextLevel <= Idle && + firstPendingTime !== nextLevel + ) { + // Don't work on Idle/Never priority unless everything else is committed. + return NoWork; + } + + return nextLevel; } // Use this function to schedule a task for a root. There's only one task per // root; if a task was already scheduled, we'll check to make sure the // expiration time of the existing task is the same as the expiration time of @@ -20425,80 +20371,70 @@ function performSyncWorkOnRoot(root) { var lastExpiredTime = root.lastExpiredTime; var expirationTime = lastExpiredTime !== NoWork ? lastExpiredTime : Sync; - if (root.finishedExpirationTime === expirationTime) { - // There's already a pending commit at this expiration time. - // TODO: This is poorly factored. This case only exists for the - // batch.commit() API. - commitRoot(root); - } else { - if (!((executionContext & (RenderContext | CommitContext)) === NoContext)) { - throw Error("Should not already be working."); - } - - flushPassiveEffects(); // If the root or expiration time have changed, throw out the existing stack - // and prepare a fresh one. Otherwise we'll continue where we left off. - - if ( - root !== workInProgressRoot || - expirationTime !== renderExpirationTime - ) { - prepareFreshStack(root, expirationTime); - startWorkOnPendingInteractions(root, expirationTime); - } // If we have a work-in-progress fiber, it means there's still work to do - // in this root. + if (!((executionContext & (RenderContext | CommitContext)) === NoContext)) { + throw Error("Should not already be working."); + } - if (workInProgress !== null) { - var prevExecutionContext = executionContext; - executionContext |= RenderContext; - var prevDispatcher = pushDispatcher(root); - var prevInteractions = pushInteractions(root); - startWorkLoopTimer(workInProgress); + flushPassiveEffects(); // If the root or expiration time have changed, throw out the existing stack + // and prepare a fresh one. Otherwise we'll continue where we left off. - do { - try { - workLoopSync(); - break; - } catch (thrownValue) { - handleError(root, thrownValue); - } - } while (true); + if (root !== workInProgressRoot || expirationTime !== renderExpirationTime) { + prepareFreshStack(root, expirationTime); + startWorkOnPendingInteractions(root, expirationTime); + } // If we have a work-in-progress fiber, it means there's still work to do + // in this root. - resetContextDependencies(); - executionContext = prevExecutionContext; - popDispatcher(prevDispatcher); + if (workInProgress !== null) { + var prevExecutionContext = executionContext; + executionContext |= RenderContext; + var prevDispatcher = pushDispatcher(root); + var prevInteractions = pushInteractions(root); + startWorkLoopTimer(workInProgress); - if (enableSchedulerTracing) { - popInteractions(prevInteractions); + do { + try { + workLoopSync(); + break; + } catch (thrownValue) { + handleError(root, thrownValue); } + } while (true); - if (workInProgressRootExitStatus === RootFatalErrored) { - var fatalError = workInProgressRootFatalError; - stopInterruptedWorkLoopTimer(); - prepareFreshStack(root, expirationTime); - markRootSuspendedAtTime(root, expirationTime); - ensureRootIsScheduled(root); - throw fatalError; - } + resetContextDependencies(); + executionContext = prevExecutionContext; + popDispatcher(prevDispatcher); - if (workInProgress !== null) { - // This is a sync render, so we should have finished the whole tree. - { - throw Error( - "Cannot commit an incomplete root. This error is likely caused by a bug in React. Please file an issue." - ); - } - } else { - // We now have a consistent tree. Because this is a sync render, we - // will commit it even if something suspended. - stopFinishedWorkLoopTimer(); - root.finishedWork = root.current.alternate; - root.finishedExpirationTime = expirationTime; - finishSyncRender(root, workInProgressRootExitStatus, expirationTime); - } // Before exiting, make sure there's a callback scheduled for the next - // pending level. + if (enableSchedulerTracing) { + popInteractions(prevInteractions); + } + if (workInProgressRootExitStatus === RootFatalErrored) { + var fatalError = workInProgressRootFatalError; + stopInterruptedWorkLoopTimer(); + prepareFreshStack(root, expirationTime); + markRootSuspendedAtTime(root, expirationTime); ensureRootIsScheduled(root); + throw fatalError; } + + 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." + ); + } + } else { + // We now have a consistent tree. Because this is a sync render, we + // will commit it even if something suspended. + stopFinishedWorkLoopTimer(); + root.finishedWork = root.current.alternate; + root.finishedExpirationTime = expirationTime; + finishSyncRender(root, workInProgressRootExitStatus, expirationTime); + } // Before exiting, make sure there's a callback scheduled for the next + // pending level. + + ensureRootIsScheduled(root); } return null; @@ -20526,12 +20462,13 @@ function flushDiscreteUpdates() { (executionContext & (BatchedContext | RenderContext | CommitContext)) !== NoContext ) { - if (true && (executionContext & RenderContext) !== NoContext) { - warning$1( - false, - "unstable_flushDiscreteUpdates: Cannot flush updates when React is " + - "already rendering." - ); + { + if ((executionContext & RenderContext) !== NoContext) { + error( + "unstable_flushDiscreteUpdates: Cannot flush updates when React is " + + "already rendering." + ); + } } // We're already rendering, so we can't synchronously flush pending work. // This is probably a nested event dispatch triggered by a lifecycle/effect, // like `el.focus()`. Exit. @@ -21117,7 +21054,16 @@ function commitRoot(root) { } function commitRootImpl(root, renderPriorityLevel) { - flushPassiveEffects(); + do { + // `flushPassiveEffects` will call `flushSyncUpdateQueue` at the end, which + // means `flushPassiveEffects` will sometimes result in additional + // passive effects. So we need to keep flushing in a loop until there are + // no more pending effects. + // TODO: Might be better if `flushPassiveEffects` did not automatically + // flush synchronous work at the end, to avoid factoring hazards like this. + flushPassiveEffects(); + } while (rootWithPendingPassiveEffects !== null); + flushRenderPhaseStrictModeWarningsInDEV(); if (!((executionContext & (RenderContext | CommitContext)) === NoContext)) { @@ -21211,8 +21157,8 @@ function commitRootImpl(root, renderPriorityLevel) { throw Error("Should be working on an effect."); } - var error = clearCaughtError(); - captureCommitPhaseError(nextEffect, error); + var error$$1 = clearCaughtError(); + captureCommitPhaseError(nextEffect, error$$1); nextEffect = nextEffect.nextEffect; } } @@ -21584,8 +21530,8 @@ function flushPassiveEffectsImpl() { throw Error("Should be working on an effect."); } - var error = clearCaughtError(); - captureCommitPhaseError(effect, error); + var error$$1 = clearCaughtError(); + captureCommitPhaseError(effect, error$$1); } resetCurrentFiber(); @@ -21625,17 +21571,17 @@ function markLegacyErrorBoundaryAsFailed(instance) { } } -function prepareToThrowUncaughtError(error) { +function prepareToThrowUncaughtError(error$$1) { if (!hasUncaughtError) { hasUncaughtError = true; - firstUncaughtError = error; + firstUncaughtError = error$$1; } } var onUncaughtError = prepareToThrowUncaughtError; -function captureCommitPhaseErrorOnRoot(rootFiber, sourceFiber, error) { - var errorInfo = createCapturedValue(error, sourceFiber); +function captureCommitPhaseErrorOnRoot(rootFiber, sourceFiber, error$$1) { + var errorInfo = createCapturedValue(error$$1, sourceFiber); var update = createRootErrorUpdate(rootFiber, errorInfo, Sync); enqueueUpdate(rootFiber, update); var root = markUpdateTimeFromFiberToRoot(rootFiber, Sync); @@ -21646,11 +21592,11 @@ function captureCommitPhaseErrorOnRoot(rootFiber, sourceFiber, error) { } } -function captureCommitPhaseError(sourceFiber, error) { +function captureCommitPhaseError(sourceFiber, error$$1) { if (sourceFiber.tag === HostRoot) { // Error was thrown at the root. There is no parent, so the root // itself should capture it. - captureCommitPhaseErrorOnRoot(sourceFiber, sourceFiber, error); + captureCommitPhaseErrorOnRoot(sourceFiber, sourceFiber, error$$1); return; } @@ -21658,7 +21604,7 @@ function captureCommitPhaseError(sourceFiber, error) { while (fiber !== null) { if (fiber.tag === HostRoot) { - captureCommitPhaseErrorOnRoot(fiber, sourceFiber, error); + captureCommitPhaseErrorOnRoot(fiber, sourceFiber, error$$1); return; } else if (fiber.tag === ClassComponent) { var ctor = fiber.type; @@ -21669,7 +21615,7 @@ function captureCommitPhaseError(sourceFiber, error) { (typeof instance.componentDidCatch === "function" && !isAlreadyFailedLegacyErrorBoundary(instance)) ) { - var errorInfo = createCapturedValue(error, sourceFiber); + var errorInfo = createCapturedValue(error$$1, sourceFiber); var update = createClassErrorUpdate( fiber, errorInfo, // TODO: This is always sync @@ -21743,7 +21689,7 @@ function pingSuspendedRoot(root, thenable, suspendedTime) { root.lastPingedTime = suspendedTime; - if (root.finishedExpirationTime === suspendedTime) { + if (!enableTrainModelFix && root.finishedExpirationTime === suspendedTime) { // If there's a pending fallback waiting to commit, throw it away. root.finishedExpirationTime = NoWork; root.finishedWork = null; @@ -21897,8 +21843,8 @@ function checkForNestedUpdates() { { if (nestedPassiveUpdateCount > NESTED_PASSIVE_UPDATE_LIMIT) { nestedPassiveUpdateCount = 0; - warning$1( - false, + + error( "Maximum update depth exceeded. This can happen when a component " + "calls setState inside useEffect, but useEffect either doesn't " + "have a dependency array, or one of the dependencies changes on " + @@ -21953,7 +21899,8 @@ function warnAboutUpdateOnUnmountedFiberInDEV(fiber) { tag !== FunctionComponent && tag !== ForwardRef && tag !== MemoComponent && - tag !== SimpleMemoComponent + tag !== SimpleMemoComponent && + tag !== Chunk ) { // Only warn for user-defined components, not internal ones like Suspense. return; @@ -21972,8 +21919,7 @@ function warnAboutUpdateOnUnmountedFiberInDEV(fiber) { didWarnStateUpdateForUnmountedComponent = new Set([componentName]); } - warningWithoutStack$1( - false, + error( "Can't perform a React state update on an unmounted component. This " + "is a no-op, but it indicates a memory leak in your application. To " + "fix, cancel all subscriptions and asynchronous tasks in %s.%s", @@ -22064,10 +22010,10 @@ function warnAboutInvalidUpdatesOnClassComponentsInDEV(fiber) { return; } - warningWithoutStack$1( - false, + error( "setState(...): Cannot call setState() inside getChildContext()" ); + didWarnAboutUpdateInGetChildContext = true; break; @@ -22076,12 +22022,12 @@ function warnAboutInvalidUpdatesOnClassComponentsInDEV(fiber) { return; } - warningWithoutStack$1( - false, + error( "Cannot update during an existing state transition (such as " + "within `render`). Render methods should be a pure function of " + "props and state." ); + didWarnAboutUpdateInRender = true; break; } @@ -22099,8 +22045,7 @@ function warnIfNotScopedWithMatchingAct(fiber) { IsSomeRendererActing.current === true && IsThisRendererActing.current !== true ) { - warningWithoutStack$1( - false, + 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" + @@ -22126,8 +22071,7 @@ function warnIfNotCurrentlyActingEffectsInDEV(fiber) { IsSomeRendererActing.current === false && IsThisRendererActing.current === false ) { - warningWithoutStack$1( - 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" + @@ -22154,8 +22098,7 @@ function warnIfNotCurrentlyActingUpdatesInDEV(fiber) { IsSomeRendererActing.current === false && IsThisRendererActing.current === false ) { - warningWithoutStack$1( - false, + error( "An update to %s inside a test was not wrapped in act(...).\n\n" + "When testing, code that causes React state updates should be " + "wrapped into act(...):\n\n" + @@ -22189,8 +22132,8 @@ function warnIfUnmockedScheduler(fiber) { ) { if (fiber.mode & BlockingMode || fiber.mode & ConcurrentMode) { didWarnAboutUnmockedScheduler = true; - warningWithoutStack$1( - false, + + 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" + @@ -22199,8 +22142,8 @@ function warnIfUnmockedScheduler(fiber) { ); } else if (warnAboutUnmockedScheduler === true) { didWarnAboutUnmockedScheduler = true; - warningWithoutStack$1( - false, + + error( 'Starting from React v17, the "scheduler" module will need to be mocked ' + "to guarantee consistent behaviour across tests and browsers. " + "For example, with jest: \n" + @@ -22237,7 +22180,7 @@ function checkForWrongSuspensePriorityInDEV(sourceFiber) { var updateQueue = current$$1.updateQueue; if (updateQueue !== null) { - var update = updateQueue.firstUpdate; + var update = updateQueue.baseQueue; while (update !== null) { var priorityLevel = update.priority; @@ -22268,11 +22211,11 @@ function checkForWrongSuspensePriorityInDEV(sourceFiber) { case FunctionComponent: case ForwardRef: case SimpleMemoComponent: - if ( - workInProgressNode.memoizedState !== null && - workInProgressNode.memoizedState.baseUpdate !== null - ) { - var _update = workInProgressNode.memoizedState.baseUpdate; // Loop through the functional component's memoized state to see whether + case Chunk: { + var firstHook = current$$1.memoizedState; // TODO: This just checks the first Hook. Isn't it suppose to check all Hooks? + + if (firstHook !== null && firstHook.baseQueue !== null) { + var _update = firstHook.baseQueue; // Loop through the functional component's memoized state to see whether // the component has triggered any high pri updates while (_update !== null) { @@ -22295,9 +22238,7 @@ function checkForWrongSuspensePriorityInDEV(sourceFiber) { break; } - if ( - _update.next === workInProgressNode.memoizedState.baseUpdate - ) { + if (_update.next === firstHook.baseQueue) { break; } @@ -22306,6 +22247,7 @@ function checkForWrongSuspensePriorityInDEV(sourceFiber) { } break; + } default: break; @@ -22328,8 +22270,7 @@ function flushSuspensePriorityWarningInDEV() { componentsThatTriggeredHighPriSuspend = null; if (componentNames.length > 0) { - warningWithoutStack$1( - false, + error( "%s triggered a user-blocking update that suspended." + "\n\n" + "The fix is to split the update into multiple parts: a user-blocking " + @@ -22442,10 +22383,10 @@ function startWorkOnPendingInteractions(root, expirationTime) { try { subscriber.onWorkStarted(interactions, threadID); - } catch (error) { + } catch (error$$1) { // If the subscriber throws, rethrow it in a separate task scheduleCallback(ImmediatePriority, function() { - throw error; + throw error$$1; }); } } @@ -22467,10 +22408,10 @@ function finishPendingInteractions(root, committedExpirationTime) { var threadID = computeThreadID(root, committedExpirationTime); subscriber.onWorkStopped(root.memoizedInteractions, threadID); } - } catch (error) { + } catch (error$$1) { // If the subscriber throws, rethrow it in a separate task scheduleCallback(ImmediatePriority, function() { - throw error; + throw error$$1; }); } finally { // Clear completed interactions from the pending Map. @@ -22492,10 +22433,10 @@ function finishPendingInteractions(root, committedExpirationTime) { if (subscriber !== null && interaction.__count === 0) { try { subscriber.onInteractionScheduledWorkCompleted(interaction); - } catch (error) { + } catch (error$$1) { // If the subscriber throws, rethrow it in a separate task scheduleCallback(ImmediatePriority, function() { - throw error; + throw error$$1; }); } } @@ -22505,6 +22446,7 @@ function finishPendingInteractions(root, committedExpirationTime) { } } +var onScheduleFiberRoot = null; var onCommitFiberRoot = null; var onCommitFiberUnmount = null; var hasLoggedError = false; @@ -22526,8 +22468,7 @@ function injectInternals(internals) { if (!hook.supportsFiber) { { - warningWithoutStack$1( - false, + error( "The installed version of React DevTools is too old and will not work " + "with the current version of React. Please update React DevTools. " + "https://fb.me/react-devtools" @@ -22540,6 +22481,23 @@ function injectInternals(internals) { try { var rendererID = hook.inject(internals); // We have successfully injected, so now it is safe to set up hooks. + { + // Only used by Fast Refresh + if (typeof hook.onScheduleFiberRoot === "function") { + onScheduleFiberRoot = function(root, children) { + try { + hook.onScheduleFiberRoot(rendererID, root, children); + } catch (err) { + if (true && !hasLoggedError) { + hasLoggedError = true; + + error("React instrumentation encountered an error: %s", err); + } + } + }; + } + } + onCommitFiberRoot = function(root, expirationTime) { try { var didError = (root.current.effectTag & DidCapture) === DidCapture; @@ -22555,13 +22513,12 @@ function injectInternals(internals) { hook.onCommitFiberRoot(rendererID, root, undefined, didError); } } catch (err) { - if (true && !hasLoggedError) { - hasLoggedError = true; - warningWithoutStack$1( - false, - "React DevTools encountered an error: %s", - err - ); + { + if (!hasLoggedError) { + hasLoggedError = true; + + error("React instrumentation encountered an error: %s", err); + } } } }; @@ -22570,29 +22527,29 @@ function injectInternals(internals) { try { hook.onCommitFiberUnmount(rendererID, fiber); } catch (err) { - if (true && !hasLoggedError) { - hasLoggedError = true; - warningWithoutStack$1( - false, - "React DevTools encountered an error: %s", - err - ); + { + if (!hasLoggedError) { + hasLoggedError = true; + + error("React instrumentation encountered an error: %s", err); + } } } }; } catch (err) { // Catch all errors because it is unsafe to throw during initialization. { - warningWithoutStack$1( - false, - "React DevTools encountered an error: %s.", - err - ); + error("React instrumentation encountered an error: %s.", err); } } // DevTools exists return true; } +function onScheduleRoot(root, children) { + if (typeof onScheduleFiberRoot === "function") { + onScheduleFiberRoot(root, children); + } +} function onCommitRoot(root, expirationTime) { if (typeof onCommitFiberRoot === "function") { onCommitFiberRoot(root, expirationTime); @@ -22740,6 +22697,12 @@ function resolveLazyComponentTag(Component) { if ($$typeof === REACT_MEMO_TYPE) { return MemoComponent; } + + if (enableChunksAPI) { + if ($$typeof === REACT_CHUNK_TYPE) { + return Chunk; + } + } } return IndeterminateComponent; @@ -23020,6 +22983,10 @@ function createFiberFromTypeAndProps( resolvedType = null; break getTag; + case REACT_CHUNK_TYPE: + fiberTag = Chunk; + break getTag; + case REACT_FUNDAMENTAL_TYPE: if (enableFundamentalAPI) { return createFiberFromFundamental( @@ -23145,8 +23112,7 @@ function createFiberFromProfiler(pendingProps, mode, expirationTime, key) { typeof pendingProps.id !== "string" || typeof pendingProps.onRender !== "function" ) { - warningWithoutStack$1( - false, + error( 'Profiler must specify an "id" string and "onRender" function as props' ); } @@ -23308,6 +23274,7 @@ function createFiberRoot(containerInfo, tag, hydrate, hydrationCallbacks) { var uninitializedFiber = createHostRootFiber(tag); root.current = uninitializedFiber; uninitializedFiber.stateNode = root; + initializeUpdateQueue(uninitializedFiber); return root; } function isRootSuspendedAtTime(root, expirationTime) { @@ -23401,15 +23368,6 @@ function markRootExpiredAtTime(root, expirationTime) { } } -// This lets us hook into Fiber to debug what it's doing. -// See https://github.com/facebook/react/pull/8033. -// This is not part of the public API, not even for React DevTools. -// You may only inject a debugTool if you work on React Fiber itself. -var ReactFiberInstrumentation = { - debugTool: null -}; -var ReactFiberInstrumentation_1 = ReactFiberInstrumentation; - var didWarnAboutNestedUpdates; var didWarnAboutFindNodeInStrictMode; @@ -23496,8 +23454,7 @@ function findHostInstanceWithWarning(component, methodName) { didWarnAboutFindNodeInStrictMode[componentName] = true; if (fiber.mode & StrictMode) { - warningWithoutStack$1( - false, + error( "%s is deprecated in StrictMode. " + "%s was passed an instance of %s which is inside StrictMode. " + "Instead, add a ref directly to the element you want to reference. " + @@ -23509,8 +23466,7 @@ function findHostInstanceWithWarning(component, methodName) { getStackByFiberInDevAndProd(hostFiber) ); } else { - warningWithoutStack$1( - false, + error( "%s is deprecated in StrictMode. " + "%s was passed an instance of %s which renders StrictMode children. " + "Instead, add a ref directly to the element you want to reference. " + @@ -23535,6 +23491,10 @@ function createContainer(containerInfo, tag, hydrate, hydrationCallbacks) { return createFiberRoot(containerInfo, tag, hydrate, hydrationCallbacks); } function updateContainer(element, container, parentComponent, callback) { + { + onScheduleRoot(container, element); + } + var current$$1 = container.current; var currentTime = requestCurrentTimeForUpdate(); @@ -23552,19 +23512,6 @@ function updateContainer(element, container, parentComponent, callback) { current$$1, suspenseConfig ); - - { - if (ReactFiberInstrumentation_1.debugTool) { - if (current$$1.alternate === null) { - ReactFiberInstrumentation_1.debugTool.onMountContainer(container); - } else if (element === null) { - ReactFiberInstrumentation_1.debugTool.onUnmountContainer(container); - } else { - ReactFiberInstrumentation_1.debugTool.onUpdateContainer(container); - } - } - } - var context = getContextForSubtree(parentComponent); if (container.context === null) { @@ -23576,8 +23523,8 @@ function updateContainer(element, container, parentComponent, callback) { { if (phase === "render" && current !== null && !didWarnAboutNestedUpdates) { didWarnAboutNestedUpdates = true; - warningWithoutStack$1( - false, + + error( "Render methods should be a pure function of props and state; " + "triggering nested component updates from render is not allowed. " + "If necessary, trigger nested updates in componentDidUpdate.\n\n" + @@ -23596,14 +23543,16 @@ function updateContainer(element, container, parentComponent, callback) { callback = callback === undefined ? null : callback; if (callback !== null) { - !(typeof callback === "function") - ? warningWithoutStack$1( - false, + { + if (typeof callback !== "function") { + error( "render(...): Expected the last optional `callback` argument to be a " + "function. Instead received: %s.", callback - ) - : void 0; + ); + } + } + update.callback = callback; } @@ -23761,7 +23710,7 @@ function createPortal( // TODO: this is special because it gets imported during build. -var ReactVersion = "16.11.0"; +var ReactVersion = "16.12.0-experimental-19f6fe170"; var NativeMethodsMixin = function(findNodeHandle, findHostInstance) { /** @@ -23805,7 +23754,7 @@ var NativeMethodsMixin = function(findNodeHandle, findHostInstance) { try { maybeInstance = findHostInstance(this); - } catch (error) {} // If there is no host component beneath this we should fail silently. + } catch (error$$1) {} // If there is no host component beneath this we should fail silently. // This is not an error; it could mean a class component rendered null. if (maybeInstance == null) { @@ -23851,7 +23800,7 @@ var NativeMethodsMixin = function(findNodeHandle, findHostInstance) { try { maybeInstance = findHostInstance(this); - } catch (error) {} // If there is no host component beneath this we should fail silently. + } catch (error$$1) {} // If there is no host component beneath this we should fail silently. // This is not an error; it could mean a class component rendered null. if (maybeInstance == null) { @@ -23895,7 +23844,7 @@ var NativeMethodsMixin = function(findNodeHandle, findHostInstance) { try { maybeInstance = findHostInstance(this); - } catch (error) {} // If there is no host component beneath this we should fail silently. + } catch (error$$1) {} // If there is no host component beneath this we should fail silently. // This is not an error; it could mean a class component rendered null. if (maybeInstance == null) { @@ -23903,12 +23852,14 @@ var NativeMethodsMixin = function(findNodeHandle, findHostInstance) { } if (maybeInstance.canonical) { - warningWithoutStack$1( - false, - "Warning: measureLayout on components using NativeMethodsMixin " + - "or ReactNative.NativeComponent is not currently supported in Fabric. " + - "measureLayout must be called on a native ref. Consider using forwardRef." - ); + { + error( + "Warning: measureLayout on components using NativeMethodsMixin " + + "or ReactNative.NativeComponent is not currently supported in Fabric. " + + "measureLayout must be called on a native ref. Consider using forwardRef." + ); + } + return; } else { var relativeNode; @@ -23921,10 +23872,12 @@ var NativeMethodsMixin = function(findNodeHandle, findHostInstance) { } if (relativeNode == null) { - warningWithoutStack$1( - false, - "Warning: ref.measureLayout must be called with a node handle or a ref to a native component." - ); + { + error( + "Warning: ref.measureLayout must be called with a node handle or a ref to a native component." + ); + } + return; } @@ -23956,7 +23909,7 @@ var NativeMethodsMixin = function(findNodeHandle, findHostInstance) { try { maybeInstance = findHostInstance(this); - } catch (error) {} // If there is no host component beneath this we should fail silently. + } catch (error$$1) {} // If there is no host component beneath this we should fail silently. // This is not an error; it could mean a class component rendered null. if (maybeInstance == null) { @@ -23964,10 +23917,10 @@ var NativeMethodsMixin = function(findNodeHandle, findHostInstance) { } if (maybeInstance.canonical) { - warningWithoutStack$1( - false, - "Warning: setNativeProps is not currently supported in Fabric" - ); + { + error("Warning: setNativeProps is not currently supported in Fabric"); + } + return; } @@ -24133,7 +24086,7 @@ var ReactNativeComponent = function(findNodeHandle, findHostInstance) { try { maybeInstance = findHostInstance(this); - } catch (error) {} // If there is no host component beneath this we should fail silently. + } catch (error$$1) {} // If there is no host component beneath this we should fail silently. // This is not an error; it could mean a class component rendered null. if (maybeInstance == null) { @@ -24177,7 +24130,7 @@ var ReactNativeComponent = function(findNodeHandle, findHostInstance) { try { maybeInstance = findHostInstance(this); - } catch (error) {} // If there is no host component beneath this we should fail silently. + } catch (error$$1) {} // If there is no host component beneath this we should fail silently. // This is not an error; it could mean a class component rendered null. if (maybeInstance == null) { @@ -24218,7 +24171,7 @@ var ReactNativeComponent = function(findNodeHandle, findHostInstance) { try { maybeInstance = findHostInstance(this); - } catch (error) {} // If there is no host component beneath this we should fail silently. + } catch (error$$1) {} // If there is no host component beneath this we should fail silently. // This is not an error; it could mean a class component rendered null. if (maybeInstance == null) { @@ -24226,12 +24179,14 @@ var ReactNativeComponent = function(findNodeHandle, findHostInstance) { } if (maybeInstance.canonical) { - warningWithoutStack$1( - false, - "Warning: measureLayout on components using NativeMethodsMixin " + - "or ReactNative.NativeComponent is not currently supported in Fabric. " + - "measureLayout must be called on a native ref. Consider using forwardRef." - ); + { + error( + "Warning: measureLayout on components using NativeMethodsMixin " + + "or ReactNative.NativeComponent is not currently supported in Fabric. " + + "measureLayout must be called on a native ref. Consider using forwardRef." + ); + } + return; } else { var relativeNode; @@ -24244,10 +24199,12 @@ var ReactNativeComponent = function(findNodeHandle, findHostInstance) { } if (relativeNode == null) { - warningWithoutStack$1( - false, - "Warning: ref.measureLayout must be called with a node handle or a ref to a native component." - ); + { + error( + "Warning: ref.measureLayout must be called with a node handle or a ref to a native component." + ); + } + return; } @@ -24279,7 +24236,7 @@ var ReactNativeComponent = function(findNodeHandle, findHostInstance) { try { maybeInstance = findHostInstance(this); - } catch (error) {} // If there is no host component beneath this we should fail silently. + } catch (error$$1) {} // If there is no host component beneath this we should fail silently. // This is not an error; it could mean a class component rendered null. if (maybeInstance == null) { @@ -24287,10 +24244,12 @@ var ReactNativeComponent = function(findNodeHandle, findHostInstance) { } if (maybeInstance.canonical) { - warningWithoutStack$1( - false, - "Warning: setNativeProps is not currently supported in Fabric" - ); + { + error( + "Warning: setNativeProps is not currently supported in Fabric" + ); + } + return; } @@ -24435,17 +24394,17 @@ function findHostInstance_DEPRECATED(componentOrHandle) { var owner = ReactCurrentOwner.current; if (owner !== null && owner.stateNode !== null) { - !owner.stateNode._warnedAboutRefsInRender - ? warningWithoutStack$1( - false, - "%s is accessing findNodeHandle inside its render(). " + - "render() should be a pure function of props and state. It should " + - "never access something that requires stale data from the previous " + - "render, such as refs. Move this logic to componentDidMount and " + - "componentDidUpdate instead.", - getComponentName(owner.type) || "A component" - ) - : void 0; + if (!owner.stateNode._warnedAboutRefsInRender) { + error( + "%s is accessing findNodeHandle inside its render(). " + + "render() should be a pure function of props and state. It should " + + "never access something that requires stale data from the previous " + + "render, such as refs. Move this logic to componentDidMount and " + + "componentDidUpdate instead.", + getComponentName(owner.type) || "A component" + ); + } + owner.stateNode._warnedAboutRefsInRender = true; } } @@ -24488,17 +24447,17 @@ function findNodeHandle(componentOrHandle) { var owner = ReactCurrentOwner.current; if (owner !== null && owner.stateNode !== null) { - !owner.stateNode._warnedAboutRefsInRender - ? warningWithoutStack$1( - false, - "%s is accessing findNodeHandle inside its render(). " + - "render() should be a pure function of props and state. It should " + - "never access something that requires stale data from the previous " + - "render, such as refs. Move this logic to componentDidMount and " + - "componentDidUpdate instead.", - getComponentName(owner.type) || "A component" - ) - : void 0; + if (!owner.stateNode._warnedAboutRefsInRender) { + error( + "%s is accessing findNodeHandle inside its render(). " + + "render() should be a pure function of props and state. It should " + + "never access something that requires stale data from the previous " + + "render, such as refs. Move this logic to componentDidMount and " + + "componentDidUpdate instead.", + getComponentName(owner.type) || "A component" + ); + } + owner.stateNode._warnedAboutRefsInRender = true; } } @@ -24567,21 +24526,29 @@ var ReactNativeRenderer = { findNodeHandle: findNodeHandle, dispatchCommand: function(handle, command, args) { if (handle._nativeTag == null) { - !(handle._nativeTag != null) - ? warningWithoutStack$1( - false, - "dispatchCommand was called with a ref that isn't a " + - "native component. Use React.forwardRef to get access to the underlying native component" - ) - : void 0; + { + error( + "dispatchCommand was called with a ref that isn't a " + + "native component. Use React.forwardRef to get access to the underlying native component" + ); + } + return; } - ReactNativePrivateInterface.UIManager.dispatchViewManagerCommand( - handle._nativeTag, - command, - args - ); + if (handle._internalInstanceHandle) { + nativeFabricUIManager.dispatchCommand( + handle._internalInstanceHandle.stateNode.node, + command, + args + ); + } else { + ReactNativePrivateInterface.UIManager.dispatchViewManagerCommand( + handle._nativeTag, + command, + args + ); + } }, render: function(element, containerTag, callback) { var root = roots.get(containerTag); diff --git a/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js b/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js index 4aa16ac835491d..991466c68dda2a 100644 --- a/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js +++ b/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js @@ -16,13 +16,110 @@ if (__DEV__) { (function() { "use strict"; +var React = require("react"); require("react-native/Libraries/ReactPrivate/ReactNativePrivateInitializeCore"); var ReactNativePrivateInterface = require("react-native/Libraries/ReactPrivate/ReactNativePrivateInterface"); -var React = require("react"); var checkPropTypes = require("prop-types/checkPropTypes"); var Scheduler = require("scheduler"); var tracing = require("scheduler/tracing"); +var ReactSharedInternals = + React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED; // Prevent newer renderers from RTE when used with older react package versions. +// Current owner and dispatcher used to share the same ref, +// but PR #14548 split them out to better support the react-debug-tools package. + +if (!ReactSharedInternals.hasOwnProperty("ReactCurrentDispatcher")) { + ReactSharedInternals.ReactCurrentDispatcher = { + current: null + }; +} + +if (!ReactSharedInternals.hasOwnProperty("ReactCurrentBatchConfig")) { + ReactSharedInternals.ReactCurrentBatchConfig = { + suspense: null + }; +} + +// by calls to these methods by a Babel plugin. +// +// In PROD (or in packages without access to React internals), +// they are left as they are instead. + +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]; + } + + 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]; + } + + printWarning("error", format, args); + } +} + +function printWarning(level, format, args) { + // When changing this logic, you might want to also + // update consoleWithStackDev.www.js as well. + { + var hasExistingStack = + args.length > 0 && + typeof args[args.length - 1] === "string" && + args[args.length - 1].indexOf("\n in") === 0; + + if (!hasExistingStack) { + var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame; + var stack = ReactDebugCurrentFrame.getStackAddendum(); + + if (stack !== "") { + format += "%s"; + args = args.concat([stack]); + } + } + + var argsWithFormat = args.map(function(item) { + return "" + item; + }); // Careful: RN currently depends on this prefix + + argsWithFormat.unshift("Warning: " + format); // We intentionally don't use spread (or .apply) directly because it + // breaks IE9: https://github.com/facebook/react/issues/13610 + // eslint-disable-next-line react-internal/no-production-logging + + Function.prototype.apply.call(console[level], console, argsWithFormat); + + try { + // --- Welcome to debugging React --- + // This error was thrown as a convenience so that you can use this stack + // to find the callsite that caused this warning to fire. + var argIndex = 0; + var message = + "Warning: " + + format.replace(/%s/g, function() { + return args[argIndex++]; + }); + throw new Error(message); + } catch (x) {} + } +} + /** * Use invariant() to assert state which your program assumes to be true. * @@ -560,71 +657,6 @@ function clearCaughtError() { } } -/** - * Similar to invariant but only logs a warning if the condition is not met. - * This can be used to log issues in development environments in critical - * paths. Removing the logging code for production environments will keep the - * same logic and follow the same code paths. - */ -var warningWithoutStack = function() {}; - -{ - warningWithoutStack = function(condition, format) { - for ( - var _len = arguments.length, - args = new Array(_len > 2 ? _len - 2 : 0), - _key = 2; - _key < _len; - _key++ - ) { - args[_key - 2] = arguments[_key]; - } - - if (format === undefined) { - throw new Error( - "`warningWithoutStack(condition, format, ...args)` requires a warning " + - "message argument" - ); - } - - if (args.length > 8) { - // Check before the condition to catch violations early. - throw new Error( - "warningWithoutStack() currently supports at most 8 arguments." - ); - } - - if (condition) { - return; - } - - if (typeof console !== "undefined") { - var argsWithFormat = args.map(function(item) { - return "" + item; - }); - argsWithFormat.unshift("Warning: " + format); // We intentionally don't use spread (or .apply) directly because it - // breaks IE9: https://github.com/facebook/react/issues/13610 - - Function.prototype.apply.call(console.error, console, argsWithFormat); - } - - try { - // --- Welcome to debugging React --- - // This error was thrown as a convenience so that you can use this stack - // to find the callsite that caused this warning to fire. - var argIndex = 0; - var message = - "Warning: " + - format.replace(/%s/g, function() { - return args[argIndex++]; - }); - throw new Error(message); - } catch (x) {} - }; -} - -var warningWithoutStack$1 = warningWithoutStack; - var getFiberCurrentPropsFromNode = null; var getInstanceFromNode = null; var getNodeFromInstance = null; @@ -638,13 +670,12 @@ function setComponentTree( getNodeFromInstance = getNodeFromInstanceImpl; { - !(getNodeFromInstance && getInstanceFromNode) - ? warningWithoutStack$1( - false, - "EventPluginUtils.setComponentTree(...): Injected " + - "module is missing getNodeFromInstance or getInstanceFromNode." - ) - : void 0; + if (!getNodeFromInstance || !getInstanceFromNode) { + error( + "EventPluginUtils.setComponentTree(...): Injected " + + "module is missing getNodeFromInstance or getInstanceFromNode." + ); + } } } var validateEventDispatches; @@ -665,9 +696,10 @@ var validateEventDispatches; : dispatchInstances ? 1 : 0; - !(instancesIsArr === listenersIsArr && instancesLen === listenersLen) - ? warningWithoutStack$1(false, "EventPluginUtils: Invalid `event`.") - : void 0; + + if (instancesIsArr !== listenersIsArr || instancesLen !== listenersLen) { + error("EventPluginUtils: Invalid `event`."); + } }; } /** @@ -1094,6 +1126,7 @@ var DehydratedFragment = 18; var SuspenseListComponent = 19; var FundamentalComponent = 20; var ScopeComponent = 21; +var Chunk = 22; function getParent(inst) { do { @@ -1231,9 +1264,9 @@ function listenerAtPhase(inst, event, propagationPhase) { function accumulateDirectionalDispatches(inst, phase, event) { { - !inst - ? warningWithoutStack$1(false, "Dispatching inst must not be null") - : void 0; + if (!inst) { + error("Dispatching inst must not be null"); + } } var listener = listenerAtPhase(inst, event, phase); @@ -1578,7 +1611,7 @@ function getPooledWarningPropertyDefinition(propName, getVal) { function set(val) { var action = isFunction ? "setting the method" : "setting the property"; - warn(action, "This is effectively a no-op"); + warn$$1(action, "This is effectively a no-op"); return val; } @@ -1587,24 +1620,22 @@ function getPooledWarningPropertyDefinition(propName, getVal) { var result = isFunction ? "This is a no-op function" : "This is set to null"; - warn(action, result); + warn$$1(action, result); return getVal; } - function warn(action, result) { - var warningCondition = false; - !warningCondition - ? warningWithoutStack$1( - false, - "This synthetic event is reused for performance reasons. If you're seeing this, " + - "you're %s `%s` on a released/nullified synthetic event. %s. " + - "If you must keep the original synthetic event around, use event.persist(). " + - "See https://fb.me/react-event-pooling for more information.", - action, - propName, - result - ) - : void 0; + function warn$$1(action, result) { + { + error( + "This synthetic event is reused for performance reasons. If you're seeing this, " + + "you're %s `%s` on a released/nullified synthetic event. %s. " + + "If you must keep the original synthetic event around, use event.persist(). " + + "See https://fb.me/react-event-pooling for more information.", + action, + propName, + result + ); + } } } @@ -1749,15 +1780,14 @@ function getTouchIdentifier(_ref) { } { - !(identifier <= MAX_TOUCH_BANK) - ? warningWithoutStack$1( - false, - "Touch identifier %s is greater than maximum supported %s which causes " + - "performance issues backfilling array locations for all of the indices.", - identifier, - MAX_TOUCH_BANK - ) - : void 0; + if (identifier > MAX_TOUCH_BANK) { + error( + "Touch identifier %s is greater than maximum supported %s which causes " + + "performance issues backfilling array locations for all of the indices.", + identifier, + MAX_TOUCH_BANK + ); + } } return identifier; @@ -1789,12 +1819,15 @@ function recordTouchMove(touch) { touchRecord.currentTimeStamp = timestampForTouch(touch); touchHistory.mostRecentTimeStamp = timestampForTouch(touch); } else { - console.warn( - "Cannot record touch move without a touch start.\n" + "Touch Move: %s\n", - "Touch Bank: %s", - printTouch(touch), - printTouchBank() - ); + { + warn( + "Cannot record touch move without a touch start.\n" + + "Touch Move: %s\n" + + "Touch Bank: %s", + printTouch(touch), + printTouchBank() + ); + } } } @@ -1811,12 +1844,15 @@ function recordTouchEnd(touch) { touchRecord.currentTimeStamp = timestampForTouch(touch); touchHistory.mostRecentTimeStamp = timestampForTouch(touch); } else { - console.warn( - "Cannot record touch end without a touch start.\n" + "Touch End: %s\n", - "Touch Bank: %s", - printTouch(touch), - printTouchBank() - ); + { + warn( + "Cannot record touch end without a touch start.\n" + + "Touch End: %s\n" + + "Touch Bank: %s", + printTouch(touch), + printTouchBank() + ); + } } } @@ -1867,9 +1903,10 @@ var ResponderTouchHistoryStore = { { var activeRecord = touchBank[touchHistory.indexOfSingleActiveTouch]; - !(activeRecord != null && activeRecord.touchActive) - ? warningWithoutStack$1(false, "Cannot find single active touch.") - : void 0; + + if (activeRecord == null || !activeRecord.touchActive) { + error("Cannot find single active touch."); + } } } } @@ -2398,9 +2435,12 @@ var ResponderEventPlugin = { if (trackedTouchCount >= 0) { trackedTouchCount -= 1; } else { - console.warn( - "Ended a touch event which was not counted in `trackedTouchCount`." - ); + { + warn( + "Ended a touch event which was not counted in `trackedTouchCount`." + ); + } + return null; } } @@ -2575,7 +2615,9 @@ var enableProfilerTimer = true; var enableSchedulerTracing = true; var enableSuspenseServerRenderer = false; -var enableFlareAPI = false; +var enableChunksAPI = false; + +var enableDeprecatedFlareAPI = false; var enableFundamentalAPI = false; var enableScopeAPI = false; @@ -2586,6 +2628,7 @@ var warnAboutDefaultPropsOnFunctionComponents = false; var warnAboutStringRefs = false; var disableLegacyContext = false; var disableSchedulerTimeoutBasedOnReactExpirationTime = false; +var enableTrainModelFix = false; var enableNativeTargetAsInstance = false; // Only used in www builds. @@ -2664,8 +2707,13 @@ function restoreStateOfTarget(target) { ); } - var props = getFiberCurrentPropsFromNode(internalInstance.stateNode); - restoreImpl(internalInstance.stateNode, internalInstance.type, props); + var stateNode = internalInstance.stateNode; // Guard against Fiber being unmounted. + + if (stateNode) { + var _props = getFiberCurrentPropsFromNode(stateNode); + + restoreImpl(internalInstance.stateNode, internalInstance.type, _props); + } } function needsStateRestore() { @@ -2898,10 +2946,7 @@ function receiveTouches(eventTopLevelType, touches, changedIndices) { if (target !== null && target !== undefined) { if (target < 1) { { - warningWithoutStack$1( - false, - "A view is reporting that a touch occurred on tag zero." - ); + error("A view is reporting that a touch occurred on tag zero."); } } else { rootNodeID = target; @@ -2968,23 +3013,6 @@ function set(key, value) { key._reactInternalFiber = value; } -var ReactSharedInternals = - React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED; // Prevent newer renderers from RTE when used with older react package versions. -// Current owner and dispatcher used to share the same ref, -// but PR #14548 split them out to better support the react-debug-tools package. - -if (!ReactSharedInternals.hasOwnProperty("ReactCurrentDispatcher")) { - ReactSharedInternals.ReactCurrentDispatcher = { - current: null - }; -} - -if (!ReactSharedInternals.hasOwnProperty("ReactCurrentBatchConfig")) { - ReactSharedInternals.ReactCurrentBatchConfig = { - suspense: null - }; -} - // The Symbol used to tag the ReactElement-like types. If there is no native Symbol // nor polyfill, then a plain number is used for performance. var hasSymbol = typeof Symbol === "function" && Symbol.for; @@ -3011,6 +3039,7 @@ var REACT_SUSPENSE_LIST_TYPE = hasSymbol : 0xead8; var REACT_MEMO_TYPE = hasSymbol ? Symbol.for("react.memo") : 0xead3; var REACT_LAZY_TYPE = hasSymbol ? Symbol.for("react.lazy") : 0xead4; +var REACT_CHUNK_TYPE = hasSymbol ? Symbol.for("react.chunk") : 0xead9; var REACT_FUNDAMENTAL_TYPE = hasSymbol ? Symbol.for("react.fundamental") : 0xead5; @@ -3034,43 +3063,6 @@ function getIteratorFn(maybeIterable) { return null; } -/** - * Similar to invariant but only logs a warning if the condition is not met. - * This can be used to log issues in development environments in critical - * paths. Removing the logging code for production environments will keep the - * same logic and follow the same code paths. - */ - -var warning = warningWithoutStack$1; - -{ - warning = function(condition, format) { - if (condition) { - return; - } - - var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame; - var stack = ReactDebugCurrentFrame.getStackAddendum(); // eslint-disable-next-line react-internal/warning-and-invariant-args - - for ( - var _len = arguments.length, - args = new Array(_len > 2 ? _len - 2 : 0), - _key = 2; - _key < _len; - _key++ - ) { - args[_key - 2] = arguments[_key]; - } - - warningWithoutStack$1.apply( - void 0, - [false, format + "%s"].concat(args, [stack]) - ); - }; -} - -var warning$1 = warning; - var Uninitialized = -1; var Pending = 0; var Resolved = 1; @@ -3091,8 +3083,7 @@ function initializeLazyComponentType(lazyComponent) { { if (defaultExport === undefined) { - warning$1( - false, + error( "lazy: Expected the result of a dynamic import() call. " + "Instead received: %s\n\nYour code should look like: \n " + "const MyComponent = lazy(() => import('./MyComponent'))", @@ -3105,10 +3096,10 @@ function initializeLazyComponentType(lazyComponent) { lazyComponent._result = defaultExport; } }, - function(error) { + function(error$$1) { if (lazyComponent._status === Pending) { lazyComponent._status = Rejected; - lazyComponent._result = error; + lazyComponent._result = error$$1; } } ); @@ -3131,8 +3122,7 @@ function getComponentName(type) { { if (typeof type.tag === "number") { - warningWithoutStack$1( - false, + error( "Received an unexpected object in getComponentName(). " + "This is likely a bug in React. Please file an issue." ); @@ -3181,6 +3171,9 @@ function getComponentName(type) { case REACT_MEMO_TYPE: return getComponentName(type.type); + case REACT_CHUNK_TYPE: + return getComponentName(type.render); + case REACT_LAZY_TYPE: { var thenable = type; var resolvedThenable = refineResolvedLazyComponent(thenable); @@ -3304,17 +3297,18 @@ function isMounted(component) { if (owner !== null && owner.tag === ClassComponent) { var ownerFiber = owner; var instance = ownerFiber.stateNode; - !instance._warnedAboutRefsInRender - ? warningWithoutStack$1( - false, - "%s is accessing isMounted inside its render() function. " + - "render() should be a pure function of props and state. It should " + - "never access something that requires stale data from the previous " + - "render, such as refs. Move this logic to componentDidMount and " + - "componentDidUpdate instead.", - getComponentName(ownerFiber.type) || "A component" - ) - : void 0; + + if (!instance._warnedAboutRefsInRender) { + error( + "%s is accessing isMounted inside its render() function. " + + "render() should be a pure function of props and state. It should " + + "never access something that requires stale data from the previous " + + "render, such as refs. Move this logic to componentDidMount and " + + "componentDidUpdate instead.", + getComponentName(ownerFiber.type) || "A component" + ); + } + instance._warnedAboutRefsInRender = true; } } @@ -4039,17 +4033,19 @@ function throwOnStylesProp(component, props) { } } function warnForStyleProps(props, validAttributes) { - for (var key in validAttributes.style) { - if (!(validAttributes[key] || props[key] === undefined)) { - console.error( - "You are setting the style `{ " + - key + - ": ... }` as a prop. You " + - "should nest it in a style object. " + - "E.g. `{ style: { " + - key + - ": ... } }`" - ); + { + for (var key in validAttributes.style) { + if (!(validAttributes[key] || props[key] === undefined)) { + error( + "You are setting the style `{ %s" + + ": ... }` as a prop. You " + + "should nest it in a style object. " + + "E.g. `{ style: { %s" + + ": ... } }`", + key, + key + ); + } } } } @@ -4114,10 +4110,12 @@ var ReactNativeFiberHostComponent = } if (relativeNode == null) { - warningWithoutStack$1( - false, - "Warning: ref.measureLayout must be called with a node handle or a ref to a native component." - ); + { + error( + "Warning: ref.measureLayout must be called with a node handle or a ref to a native component." + ); + } + return; } @@ -4565,7 +4563,7 @@ function unhideInstance(instance, props) { function unhideTextInstance(textInstance, text) { throw new Error("Not yet implemented."); } -function mountResponderInstance( +function DEPRECATED_mountResponderInstance( responder, responderInstance, props, @@ -4574,7 +4572,7 @@ function mountResponderInstance( ) { throw new Error("Not yet implemented."); } -function unmountResponderInstance(responderInstance) { +function DEPRECATED_unmountResponderInstance(responderInstance) { throw new Error("Not yet implemented."); } function getFundamentalComponentInstance(fundamentalInstance) { @@ -4595,6 +4593,9 @@ function unmountFundamentalComponent(fundamentalInstance) { function getInstanceFromNode$1(node) { throw new Error("Not yet implemented."); } +function beforeRemoveInstance(instance) { + // noop +} var BEFORE_SLASH_RE = /^(.*)[\\\/]/; var describeComponentFrame = function(name, source, ownerName) { @@ -5178,7 +5179,7 @@ function createCursor(defaultValue) { function pop(cursor, fiber) { if (index < 0) { { - warningWithoutStack$1(false, "Unexpected pop."); + error("Unexpected pop."); } return; @@ -5186,7 +5187,7 @@ function pop(cursor, fiber) { { if (fiber !== fiberStack[index]) { - warningWithoutStack$1(false, "Unexpected Fiber popped."); + error("Unexpected Fiber popped."); } } @@ -5373,8 +5374,8 @@ function processChildContext(fiber, type, parentContext) { if (!warnedAboutMissingGetChildContext[componentName]) { warnedAboutMissingGetChildContext[componentName] = true; - warningWithoutStack$1( - false, + + error( "%s.childContextTypes is specified but there is no getChildContext() method " + "on the instance. You can either define getChildContext() on %s or remove " + "childContextTypes from it.", @@ -5893,78 +5894,6 @@ function shallowEqual(objA, objB) { return true; } -/** - * Forked from fbjs/warning: - * https://github.com/facebook/fbjs/blob/e66ba20ad5be433eb54423f2b097d829324d9de6/packages/fbjs/src/__forks__/warning.js - * - * Only change is we use console.warn instead of console.error, - * and do nothing when 'console' is not supported. - * This really simplifies the code. - * --- - * Similar to invariant but only logs a warning if the condition is not met. - * This can be used to log issues in development environments in critical - * paths. Removing the logging code for production environments will keep the - * same logic and follow the same code paths. - */ -var lowPriorityWarningWithoutStack = function() {}; - -{ - var printWarning = function(format) { - for ( - var _len = arguments.length, - args = new Array(_len > 1 ? _len - 1 : 0), - _key = 1; - _key < _len; - _key++ - ) { - args[_key - 1] = arguments[_key]; - } - - var argIndex = 0; - var message = - "Warning: " + - format.replace(/%s/g, function() { - return args[argIndex++]; - }); - - if (typeof console !== "undefined") { - console.warn(message); - } - - try { - // --- Welcome to debugging React --- - // This error was thrown as a convenience so that you can use this stack - // to find the callsite that caused this warning to fire. - throw new Error(message); - } catch (x) {} - }; - - lowPriorityWarningWithoutStack = function(condition, format) { - if (format === undefined) { - throw new Error( - "`lowPriorityWarningWithoutStack(condition, format, ...args)` requires a warning " + - "message argument" - ); - } - - if (!condition) { - for ( - var _len2 = arguments.length, - args = new Array(_len2 > 2 ? _len2 - 2 : 0), - _key2 = 2; - _key2 < _len2; - _key2++ - ) { - args[_key2 - 2] = arguments[_key2]; - } - - printWarning.apply(void 0, [format].concat(args)); - } - }; -} - -var lowPriorityWarningWithoutStack$1 = lowPriorityWarningWithoutStack; - var ReactStrictModeWarnings = { recordUnsafeLifecycleWarnings: function(fiber, instance) {}, flushPendingUnsafeLifecycleWarnings: function() {}, @@ -6135,8 +6064,8 @@ var ReactStrictModeWarnings = { if (UNSAFE_componentWillMountUniqueNames.size > 0) { var sortedNames = setToSortedString(UNSAFE_componentWillMountUniqueNames); - warningWithoutStack$1( - false, + + error( "Using UNSAFE_componentWillMount in strict mode is not recommended and may indicate bugs in your code. " + "See https://fb.me/react-unsafe-component-lifecycles for details.\n\n" + "* Move code with side effects to componentDidMount, and set initial state in the constructor.\n" + @@ -6150,8 +6079,7 @@ var ReactStrictModeWarnings = { UNSAFE_componentWillReceivePropsUniqueNames ); - warningWithoutStack$1( - false, + error( "Using UNSAFE_componentWillReceiveProps in strict mode is not recommended " + "and may indicate bugs in your code. " + "See https://fb.me/react-unsafe-component-lifecycles for details.\n\n" + @@ -6169,8 +6097,7 @@ var ReactStrictModeWarnings = { UNSAFE_componentWillUpdateUniqueNames ); - warningWithoutStack$1( - false, + error( "Using UNSAFE_componentWillUpdate in strict mode is not recommended " + "and may indicate bugs in your code. " + "See https://fb.me/react-unsafe-component-lifecycles for details.\n\n" + @@ -6183,8 +6110,7 @@ var ReactStrictModeWarnings = { if (componentWillMountUniqueNames.size > 0) { var _sortedNames3 = setToSortedString(componentWillMountUniqueNames); - lowPriorityWarningWithoutStack$1( - false, + warn( "componentWillMount has been renamed, and is not recommended for use. " + "See https://fb.me/react-unsafe-component-lifecycles for details.\n\n" + "* Move code with side effects to componentDidMount, and set initial state in the constructor.\n" + @@ -6202,8 +6128,7 @@ var ReactStrictModeWarnings = { componentWillReceivePropsUniqueNames ); - lowPriorityWarningWithoutStack$1( - false, + warn( "componentWillReceiveProps has been renamed, and is not recommended for use. " + "See https://fb.me/react-unsafe-component-lifecycles for details.\n\n" + "* Move data fetching code or side effects to componentDidUpdate.\n" + @@ -6222,8 +6147,7 @@ var ReactStrictModeWarnings = { if (componentWillUpdateUniqueNames.size > 0) { var _sortedNames5 = setToSortedString(componentWillUpdateUniqueNames); - lowPriorityWarningWithoutStack$1( - false, + warn( "componentWillUpdate has been renamed, and is not recommended for use. " + "See https://fb.me/react-unsafe-component-lifecycles for details.\n\n" + "* Move data fetching code or side effects to componentDidUpdate.\n" + @@ -6248,11 +6172,11 @@ var ReactStrictModeWarnings = { var strictRoot = findStrictRoot(fiber); if (strictRoot === null) { - warningWithoutStack$1( - false, + error( "Expected to find a StrictMode component in a strict mode tree. " + "This error is likely caused by a bug in React. Please file an issue." ); + return; } // Dedup strategy: Warn once per component. @@ -6285,8 +6209,8 @@ var ReactStrictModeWarnings = { }); var sortedNames = setToSortedString(uniqueNames); var strictRootComponentStack = getStackByFiberInDevAndProd(strictRoot); - warningWithoutStack$1( - false, + + error( "Legacy context API has been detected within a strict-mode tree." + "\n\nThe old API will be supported in all 16.x releases, but applications " + "using it should migrate to the new version." + @@ -6819,17 +6743,17 @@ function pushProvider(providerFiber, nextValue) { context._currentValue = nextValue; { - !( - context._currentRenderer === undefined || - context._currentRenderer === null || - context._currentRenderer === rendererSigil - ) - ? warningWithoutStack$1( - false, - "Detected multiple renderers concurrently rendering the " + - "same context provider. This is currently unsupported." - ) - : void 0; + if ( + context._currentRenderer !== undefined && + context._currentRenderer !== null && + context._currentRenderer !== rendererSigil + ) { + error( + "Detected multiple renderers concurrently rendering the " + + "same context provider. This is currently unsupported." + ); + } + context._currentRenderer = rendererSigil; } } else { @@ -6837,17 +6761,17 @@ function pushProvider(providerFiber, nextValue) { context._currentValue2 = nextValue; { - !( - context._currentRenderer2 === undefined || - context._currentRenderer2 === null || - context._currentRenderer2 === rendererSigil - ) - ? warningWithoutStack$1( - false, - "Detected multiple renderers concurrently rendering the " + - "same context provider. This is currently unsupported." - ) - : void 0; + if ( + context._currentRenderer2 !== undefined && + context._currentRenderer2 !== null && + context._currentRenderer2 !== rendererSigil + ) { + error( + "Detected multiple renderers concurrently rendering the " + + "same context provider. This is currently unsupported." + ); + } + context._currentRenderer2 = rendererSigil; } } @@ -6874,14 +6798,13 @@ function calculateChangedBits(context, newValue, oldValue) { : MAX_SIGNED_31_BIT_INT; { - !((changedBits & MAX_SIGNED_31_BIT_INT) === changedBits) - ? warning$1( - false, - "calculateChangedBits: Expected the return value to be a " + - "31-bit integer. Instead received: %s", - changedBits - ) - : void 0; + if ((changedBits & MAX_SIGNED_31_BIT_INT) !== changedBits) { + error( + "calculateChangedBits: Expected the return value to be a " + + "31-bit integer. Instead received: %s", + changedBits + ); + } } return changedBits | 0; @@ -7077,15 +7000,14 @@ function readContext(context, observedBits) { { // This warning would fire if you read context inside a Hook like useMemo. // Unlike the class check below, it's not enforced in production for perf. - !!isDisallowedContextReadInDEV - ? warning$1( - false, - "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()." - ) - : void 0; + if (isDisallowedContextReadInDEV) { + 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 (lastContextWithAllBitsObserved === context) { @@ -7226,38 +7148,32 @@ var currentlyProcessingQueue; currentlyProcessingQueue = null; } -function createUpdateQueue(baseState) { +function initializeUpdateQueue(fiber) { var queue = { - baseState: baseState, - firstUpdate: null, - lastUpdate: null, - firstCapturedUpdate: null, - lastCapturedUpdate: null, - firstEffect: null, - lastEffect: null, - firstCapturedEffect: null, - lastCapturedEffect: null - }; - return queue; -} - -function cloneUpdateQueue(currentQueue) { - var queue = { - baseState: currentQueue.baseState, - firstUpdate: currentQueue.firstUpdate, - lastUpdate: currentQueue.lastUpdate, - // TODO: With resuming, if we bail out and resuse the child tree, we should - // keep these effects. - firstCapturedUpdate: null, - lastCapturedUpdate: null, - firstEffect: null, - lastEffect: null, - firstCapturedEffect: null, - lastCapturedEffect: null + baseState: fiber.memoizedState, + baseQueue: null, + shared: { + pending: null + }, + effects: null }; - return queue; + fiber.updateQueue = queue; +} +function cloneUpdateQueue(current, workInProgress) { + // Clone the update queue from current. Unless it's already a clone. + var queue = workInProgress.updateQueue; + var currentQueue = current.updateQueue; + + if (queue === currentQueue) { + var clone = { + baseState: currentQueue.baseState, + baseQueue: currentQueue.baseQueue, + shared: currentQueue.shared, + effects: currentQueue.effects + }; + workInProgress.updateQueue = clone; + } } - function createUpdate(expirationTime, suspenseConfig) { var update = { expirationTime: expirationTime, @@ -7265,9 +7181,9 @@ function createUpdate(expirationTime, suspenseConfig) { tag: UpdateState, payload: null, callback: null, - next: null, - nextEffect: null + next: null }; + update.next = update; { update.priority = getCurrentPriorityLevel(); @@ -7275,136 +7191,62 @@ function createUpdate(expirationTime, suspenseConfig) { return update; } +function enqueueUpdate(fiber, update) { + var updateQueue = fiber.updateQueue; -function appendUpdateToQueue(queue, update) { - // Append the update to the end of the list. - if (queue.lastUpdate === null) { - // Queue is empty - queue.firstUpdate = queue.lastUpdate = update; - } else { - queue.lastUpdate.next = update; - queue.lastUpdate = update; + if (updateQueue === null) { + // Only occurs if the fiber has been unmounted. + return; } -} -function enqueueUpdate(fiber, update) { - // Update queues are created lazily. - var alternate = fiber.alternate; - var queue1; - var queue2; + var sharedQueue = updateQueue.shared; + var pending = sharedQueue.pending; - if (alternate === null) { - // There's only one fiber. - queue1 = fiber.updateQueue; - queue2 = null; - - if (queue1 === null) { - queue1 = fiber.updateQueue = createUpdateQueue(fiber.memoizedState); - } + if (pending === null) { + // This is the first update. Create a circular list. + update.next = update; } else { - // There are two owners. - queue1 = fiber.updateQueue; - queue2 = alternate.updateQueue; - - if (queue1 === null) { - if (queue2 === null) { - // Neither fiber has an update queue. Create new ones. - queue1 = fiber.updateQueue = createUpdateQueue(fiber.memoizedState); - queue2 = alternate.updateQueue = createUpdateQueue( - alternate.memoizedState - ); - } else { - // Only one fiber has an update queue. Clone to create a new one. - queue1 = fiber.updateQueue = cloneUpdateQueue(queue2); - } - } else { - if (queue2 === null) { - // Only one fiber has an update queue. Clone to create a new one. - queue2 = alternate.updateQueue = cloneUpdateQueue(queue1); - } else { - // Both owners have an update queue. - } - } + update.next = pending.next; + pending.next = update; } - if (queue2 === null || queue1 === queue2) { - // There's only a single queue. - appendUpdateToQueue(queue1, update); - } else { - // There are two queues. We need to append the update to both queues, - // while accounting for the persistent structure of the list — we don't - // want the same update to be added multiple times. - if (queue1.lastUpdate === null || queue2.lastUpdate === null) { - // One of the queues is not empty. We must add the update to both queues. - appendUpdateToQueue(queue1, update); - appendUpdateToQueue(queue2, update); - } else { - // Both queues are non-empty. The last update is the same in both lists, - // because of structural sharing. So, only append to one of the lists. - appendUpdateToQueue(queue1, update); // But we still need to update the `lastUpdate` pointer of queue2. - - queue2.lastUpdate = update; - } - } + sharedQueue.pending = update; { if ( - fiber.tag === ClassComponent && - (currentlyProcessingQueue === queue1 || - (queue2 !== null && currentlyProcessingQueue === queue2)) && + currentlyProcessingQueue === sharedQueue && !didWarnUpdateInsideUpdate ) { - warningWithoutStack$1( - false, + error( "An update (setState, replaceState, or forceUpdate) was scheduled " + "from inside an update function. Update functions should be pure, " + "with zero side-effects. Consider using componentDidUpdate or a " + "callback." ); + didWarnUpdateInsideUpdate = true; } } } function enqueueCapturedUpdate(workInProgress, update) { - // Captured updates go into a separate list, and only on the work-in- - // progress queue. - var workInProgressQueue = workInProgress.updateQueue; + var current = workInProgress.alternate; - if (workInProgressQueue === null) { - workInProgressQueue = workInProgress.updateQueue = createUpdateQueue( - workInProgress.memoizedState - ); - } else { - // TODO: I put this here rather than createWorkInProgress so that we don't - // clone the queue unnecessarily. There's probably a better way to - // structure this. - workInProgressQueue = ensureWorkInProgressQueueIsAClone( - workInProgress, - workInProgressQueue - ); - } // Append the update to the end of the list. + if (current !== null) { + // Ensure the work-in-progress queue is a clone + cloneUpdateQueue(current, workInProgress); + } // Captured updates go only on the work-in-progress queue. - if (workInProgressQueue.lastCapturedUpdate === null) { - // This is the first render phase update - workInProgressQueue.firstCapturedUpdate = workInProgressQueue.lastCapturedUpdate = update; - } else { - workInProgressQueue.lastCapturedUpdate.next = update; - workInProgressQueue.lastCapturedUpdate = update; - } -} + var queue = workInProgress.updateQueue; // Append the update to the end of the list. -function ensureWorkInProgressQueueIsAClone(workInProgress, queue) { - var current = workInProgress.alternate; + var last = queue.baseQueue; - if (current !== null) { - // If the work-in-progress queue is equal to the current queue, - // we need to clone it first. - if (queue === current.updateQueue) { - queue = workInProgress.updateQueue = cloneUpdateQueue(queue); - } + if (last === null) { + queue.baseQueue = update.next = update; + update.next = update; + } else { + update.next = last.next; + last.next = update; } - - return queue; } function getStateFromUpdate( @@ -7496,163 +7338,171 @@ function getStateFromUpdate( function processUpdateQueue( workInProgress, - queue, props, instance, renderExpirationTime ) { + // This is always non-null on a ClassComponent or HostRoot + var queue = workInProgress.updateQueue; hasForceUpdate = false; - queue = ensureWorkInProgressQueueIsAClone(workInProgress, queue); { - currentlyProcessingQueue = queue; - } // These values may change as we process the queue. + currentlyProcessingQueue = queue.shared; + } // The last rebase update that is NOT part of the base state. + + var baseQueue = queue.baseQueue; // The last pending update that hasn't been processed yet. - var newBaseState = queue.baseState; - var newFirstUpdate = null; - var newExpirationTime = NoWork; // Iterate through the list of updates to compute the result. + var pendingQueue = queue.shared.pending; - var update = queue.firstUpdate; - var resultState = newBaseState; + if (pendingQueue !== null) { + // We have new updates that haven't been processed yet. + // We'll add them to the base queue. + if (baseQueue !== null) { + // Merge the pending queue and the base queue. + var baseFirst = baseQueue.next; + var pendingFirst = pendingQueue.next; + baseQueue.next = pendingFirst; + pendingQueue.next = baseFirst; + } - while (update !== null) { - var updateExpirationTime = update.expirationTime; + baseQueue = pendingQueue; + queue.shared.pending = null; // TODO: Pass `current` as argument - if (updateExpirationTime < renderExpirationTime) { - // This update does not have sufficient priority. Skip it. - if (newFirstUpdate === null) { - // This is the first skipped update. It will be the first update in - // the new list. - newFirstUpdate = update; // Since this is the first update that was skipped, the current result - // is the new base state. + var current = workInProgress.alternate; - newBaseState = resultState; - } // Since this update will remain in the list, update the remaining - // expiration time. + if (current !== null) { + var currentQueue = current.updateQueue; - if (newExpirationTime < updateExpirationTime) { - newExpirationTime = updateExpirationTime; + if (currentQueue !== null) { + currentQueue.baseQueue = pendingQueue; } - } else { - // This update does have sufficient priority. - // Mark the event time of this update as relevant to this render pass. - // TODO: This should ideally use the true event time of this update rather than - // its priority which is a derived and not reverseable value. - // TODO: We should skip this update if it was already committed but currently - // we have no way of detecting the difference between a committed and suspended - // update here. - markRenderEventTimeAndConfig(updateExpirationTime, update.suspenseConfig); // Process it and compute a new result. - - resultState = getStateFromUpdate( - workInProgress, - queue, - update, - resultState, - props, - instance - ); - var callback = update.callback; + } + } // These values may change as we process the queue. - if (callback !== null) { - workInProgress.effectTag |= Callback; // Set this to null, in case it was mutated during an aborted render. + if (baseQueue !== null) { + var first = baseQueue.next; // Iterate through the list of updates to compute the result. - update.nextEffect = null; + var newState = queue.baseState; + var newExpirationTime = NoWork; + var newBaseState = null; + var newBaseQueueFirst = null; + var newBaseQueueLast = null; - if (queue.lastEffect === null) { - queue.firstEffect = queue.lastEffect = update; - } else { - queue.lastEffect.nextEffect = update; - queue.lastEffect = update; - } - } - } // Continue to the next update. + if (first !== null) { + var update = first; - update = update.next; - } // Separately, iterate though the list of captured updates. + do { + var updateExpirationTime = update.expirationTime; + + if (updateExpirationTime < renderExpirationTime) { + // Priority is insufficient. Skip this update. If this is the first + // skipped update, the previous update/state is the new base + // update/state. + var clone = { + expirationTime: update.expirationTime, + suspenseConfig: update.suspenseConfig, + tag: update.tag, + payload: update.payload, + callback: update.callback, + next: null + }; - var newFirstCapturedUpdate = null; - update = queue.firstCapturedUpdate; + if (newBaseQueueLast === null) { + newBaseQueueFirst = newBaseQueueLast = clone; + newBaseState = newState; + } else { + newBaseQueueLast = newBaseQueueLast.next = clone; + } // Update the remaining priority in the queue. - while (update !== null) { - var _updateExpirationTime = update.expirationTime; + if (updateExpirationTime > newExpirationTime) { + newExpirationTime = updateExpirationTime; + } + } else { + // This update does have sufficient priority. + if (newBaseQueueLast !== null) { + var _clone = { + expirationTime: Sync, + // This update is going to be committed so we never want uncommit it. + suspenseConfig: update.suspenseConfig, + tag: update.tag, + payload: update.payload, + callback: update.callback, + next: null + }; + newBaseQueueLast = newBaseQueueLast.next = _clone; + } // Mark the event time of this update as relevant to this render pass. + // TODO: This should ideally use the true event time of this update rather than + // its priority which is a derived and not reverseable value. + // TODO: We should skip this update if it was already committed but currently + // we have no way of detecting the difference between a committed and suspended + // update here. + + markRenderEventTimeAndConfig( + updateExpirationTime, + update.suspenseConfig + ); // Process this update. + + newState = getStateFromUpdate( + workInProgress, + queue, + update, + newState, + props, + instance + ); + var callback = update.callback; - if (_updateExpirationTime < renderExpirationTime) { - // This update does not have sufficient priority. Skip it. - if (newFirstCapturedUpdate === null) { - // This is the first skipped captured update. It will be the first - // update in the new list. - newFirstCapturedUpdate = update; // If this is the first update that was skipped, the current result is - // the new base state. + if (callback !== null) { + workInProgress.effectTag |= Callback; + var effects = queue.effects; - if (newFirstUpdate === null) { - newBaseState = resultState; + if (effects === null) { + queue.effects = [update]; + } else { + effects.push(update); + } + } } - } // Since this update will remain in the list, update the remaining - // expiration time. - - if (newExpirationTime < _updateExpirationTime) { - newExpirationTime = _updateExpirationTime; - } - } else { - // This update does have sufficient priority. Process it and compute - // a new result. - resultState = getStateFromUpdate( - workInProgress, - queue, - update, - resultState, - props, - instance - ); - var _callback = update.callback; - if (_callback !== null) { - workInProgress.effectTag |= Callback; // Set this to null, in case it was mutated during an aborted render. + update = update.next; - update.nextEffect = null; + if (update === null || update === first) { + pendingQueue = queue.shared.pending; - if (queue.lastCapturedEffect === null) { - queue.firstCapturedEffect = queue.lastCapturedEffect = update; - } else { - queue.lastCapturedEffect.nextEffect = update; - queue.lastCapturedEffect = update; + if (pendingQueue === null) { + break; + } else { + // An update was scheduled from inside a reducer. Add the new + // pending updates to the end of the list and keep processing. + update = baseQueue.next = pendingQueue.next; + pendingQueue.next = first; + queue.baseQueue = baseQueue = pendingQueue; + queue.shared.pending = null; + } } - } + } while (true); } - update = update.next; - } - - if (newFirstUpdate === null) { - queue.lastUpdate = null; - } + if (newBaseQueueLast === null) { + newBaseState = newState; + } else { + newBaseQueueLast.next = newBaseQueueFirst; + } - if (newFirstCapturedUpdate === null) { - queue.lastCapturedUpdate = null; - } else { - workInProgress.effectTag |= Callback; - } + queue.baseState = newBaseState; + queue.baseQueue = newBaseQueueLast; // Set the remaining expiration time to be whatever is remaining in the queue. + // This should be fine because the only two other things that contribute to + // expiration time are props and context. We're already in the middle of the + // begin phase by the time we start processing the queue, so we've already + // dealt with the props. Context in components that specify + // shouldComponentUpdate is tricky; but we'll have to account for + // that regardless. - if (newFirstUpdate === null && newFirstCapturedUpdate === null) { - // We processed every update, without skipping. That means the new base - // state is the same as the result state. - newBaseState = resultState; + markUnprocessedUpdateTime(newExpirationTime); + workInProgress.expirationTime = newExpirationTime; + workInProgress.memoizedState = newState; } - queue.baseState = newBaseState; - queue.firstUpdate = newFirstUpdate; - queue.firstCapturedUpdate = newFirstCapturedUpdate; // Set the remaining expiration time to be whatever is remaining in the queue. - // This should be fine because the only two other things that contribute to - // expiration time are props and context. We're already in the middle of the - // begin phase by the time we start processing the queue, so we've already - // dealt with the props. Context in components that specify - // shouldComponentUpdate is tricky; but we'll have to account for - // that regardless. - - markUnprocessedUpdateTime(newExpirationTime); - workInProgress.expirationTime = newExpirationTime; - workInProgress.memoizedState = resultState; - { currentlyProcessingQueue = null; } @@ -7681,36 +7531,20 @@ function commitUpdateQueue( instance, renderExpirationTime ) { - // If the finished render included captured updates, and there are still - // lower priority updates left over, we need to keep the captured updates - // in the queue so that they are rebased and not dropped once we process the - // queue again at the lower priority. - if (finishedQueue.firstCapturedUpdate !== null) { - // Join the captured update list to the end of the normal list. - if (finishedQueue.lastUpdate !== null) { - finishedQueue.lastUpdate.next = finishedQueue.firstCapturedUpdate; - finishedQueue.lastUpdate = finishedQueue.lastCapturedUpdate; - } // Clear the list of captured updates. - - finishedQueue.firstCapturedUpdate = finishedQueue.lastCapturedUpdate = null; - } // Commit the effects - - commitUpdateEffects(finishedQueue.firstEffect, instance); - finishedQueue.firstEffect = finishedQueue.lastEffect = null; - commitUpdateEffects(finishedQueue.firstCapturedEffect, instance); - finishedQueue.firstCapturedEffect = finishedQueue.lastCapturedEffect = null; -} - -function commitUpdateEffects(effect, instance) { - while (effect !== null) { - var callback = effect.callback; + // Commit the effects + var effects = finishedQueue.effects; + finishedQueue.effects = null; - if (callback !== null) { - effect.callback = null; - callCallback(callback, instance); - } + if (effects !== null) { + for (var i = 0; i < effects.length; i++) { + var effect = effects[i]; + var callback = effect.callback; - effect = effect.nextEffect; + if (callback !== null) { + effect.callback = null; + callCallback(callback, instance); + } + } } } @@ -7755,8 +7589,8 @@ var didWarnAboutInvalidateContextType; if (!didWarnOnInvalidCallback.has(key)) { didWarnOnInvalidCallback.add(key); - warningWithoutStack$1( - false, + + error( "%s(...): Expected the last optional `callback` argument to be a " + "function. Instead received: %s.", callerName, @@ -7771,8 +7605,8 @@ var didWarnAboutInvalidateContextType; if (!didWarnAboutUndefinedDerivedState.has(componentName)) { didWarnAboutUndefinedDerivedState.add(componentName); - warningWithoutStack$1( - false, + + error( "%s.getDerivedStateFromProps(): A valid state object (or null) must be returned. " + "You have returned undefined.", componentName @@ -7829,9 +7663,9 @@ function applyDerivedStateFromProps( workInProgress.memoizedState = memoizedState; // Once the update queue is empty, persist the derived state onto the // base state. - var updateQueue = workInProgress.updateQueue; - - if (updateQueue !== null && workInProgress.expirationTime === NoWork) { + if (workInProgress.expirationTime === NoWork) { + // Queue is always non-null for classes + var updateQueue = workInProgress.updateQueue; updateQueue.baseState = memoizedState; } } @@ -7930,14 +7764,13 @@ function checkShouldComponentUpdate( stopPhaseTimer(); { - !(shouldUpdate !== undefined) - ? warningWithoutStack$1( - false, - "%s.shouldComponentUpdate(): Returned undefined instead of a " + - "boolean value. Make sure to return true or false.", - getComponentName(ctor) || "Component" - ) - : void 0; + if (shouldUpdate === undefined) { + error( + "%s.shouldComponentUpdate(): Returned undefined instead of a " + + "boolean value. Make sure to return true or false.", + getComponentName(ctor) || "Component" + ); + } } return shouldUpdate; @@ -7961,15 +7794,13 @@ function checkClassInstance(workInProgress, ctor, newProps) { if (!renderPresent) { if (ctor.prototype && typeof ctor.prototype.render === "function") { - warningWithoutStack$1( - false, + error( "%s(...): No `render` method found on the returned component " + "instance: did you accidentally return an object from the constructor?", name ); } else { - warningWithoutStack$1( - false, + error( "%s(...): No `render` method found on the returned component " + "instance: you may have forgotten to define `render`.", name @@ -7977,54 +7808,50 @@ function checkClassInstance(workInProgress, ctor, newProps) { } } - var noGetInitialStateOnES6 = - !instance.getInitialState || - instance.getInitialState.isReactClassApproved || - instance.state; - !noGetInitialStateOnES6 - ? warningWithoutStack$1( - false, - "getInitialState was defined on %s, a plain JavaScript class. " + - "This is only supported for classes created using React.createClass. " + - "Did you mean to define a state property instead?", - name - ) - : void 0; - var noGetDefaultPropsOnES6 = - !instance.getDefaultProps || - instance.getDefaultProps.isReactClassApproved; - !noGetDefaultPropsOnES6 - ? warningWithoutStack$1( - false, - "getDefaultProps was defined on %s, a plain JavaScript class. " + - "This is only supported for classes created using React.createClass. " + - "Use a static property to define defaultProps instead.", - name - ) - : void 0; - var noInstancePropTypes = !instance.propTypes; - !noInstancePropTypes - ? warningWithoutStack$1( - false, - "propTypes was defined as an instance property on %s. Use a static " + - "property to define propTypes instead.", - name - ) - : void 0; - var noInstanceContextType = !instance.contextType; - !noInstanceContextType - ? warningWithoutStack$1( - false, - "contextType was defined as an instance property on %s. Use a static " + - "property to define contextType instead.", - name - ) - : void 0; + if ( + instance.getInitialState && + !instance.getInitialState.isReactClassApproved && + !instance.state + ) { + error( + "getInitialState was defined on %s, a plain JavaScript class. " + + "This is only supported for classes created using React.createClass. " + + "Did you mean to define a state property instead?", + name + ); + } + + if ( + instance.getDefaultProps && + !instance.getDefaultProps.isReactClassApproved + ) { + error( + "getDefaultProps was defined on %s, a plain JavaScript class. " + + "This is only supported for classes created using React.createClass. " + + "Use a static property to define defaultProps instead.", + name + ); + } + + if (instance.propTypes) { + error( + "propTypes was defined as an instance property on %s. Use a static " + + "property to define propTypes instead.", + name + ); + } + + if (instance.contextType) { + error( + "contextType was defined as an instance property on %s. Use a static " + + "property to define contextType instead.", + name + ); + } if (disableLegacyContext) { if (ctor.childContextTypes) { - warningWithoutStack$1( - false, + error( "%s uses the legacy childContextTypes API which is no longer supported. " + "Use React.createContext() instead.", name @@ -8032,23 +7859,20 @@ function checkClassInstance(workInProgress, ctor, newProps) { } if (ctor.contextTypes) { - warningWithoutStack$1( - false, + error( "%s uses the legacy contextTypes API which is no longer supported. " + "Use React.createContext() with static contextType instead.", name ); } } else { - var noInstanceContextTypes = !instance.contextTypes; - !noInstanceContextTypes - ? warningWithoutStack$1( - false, - "contextTypes was defined as an instance property on %s. Use a static " + - "property to define contextTypes instead.", - name - ) - : void 0; + if (instance.contextTypes) { + error( + "contextTypes was defined as an instance property on %s. Use a static " + + "property to define contextTypes instead.", + name + ); + } if ( ctor.contextType && @@ -8056,8 +7880,8 @@ function checkClassInstance(workInProgress, ctor, newProps) { !didWarnAboutContextTypeAndContextTypes.has(ctor) ) { didWarnAboutContextTypeAndContextTypes.add(ctor); - warningWithoutStack$1( - false, + + error( "%s declares both contextTypes and contextType static properties. " + "The legacy contextTypes property will be ignored.", name @@ -8065,26 +7889,22 @@ function checkClassInstance(workInProgress, ctor, newProps) { } } - var noComponentShouldUpdate = - typeof instance.componentShouldUpdate !== "function"; - !noComponentShouldUpdate - ? warningWithoutStack$1( - false, - "%s has a method called " + - "componentShouldUpdate(). Did you mean shouldComponentUpdate()? " + - "The name is phrased as a question because the function is " + - "expected to return a value.", - name - ) - : void 0; + if (typeof instance.componentShouldUpdate === "function") { + error( + "%s has a method called " + + "componentShouldUpdate(). Did you mean shouldComponentUpdate()? " + + "The name is phrased as a question because the function is " + + "expected to return a value.", + name + ); + } if ( ctor.prototype && ctor.prototype.isPureReactComponent && typeof instance.shouldComponentUpdate !== "undefined" ) { - warningWithoutStack$1( - false, + error( "%s has a method called shouldComponentUpdate(). " + "shouldComponentUpdate should not be used when extending React.PureComponent. " + "Please extend React.Component if shouldComponentUpdate is used.", @@ -8092,70 +7912,61 @@ function checkClassInstance(workInProgress, ctor, newProps) { ); } - var noComponentDidUnmount = - typeof instance.componentDidUnmount !== "function"; - !noComponentDidUnmount - ? warningWithoutStack$1( - false, - "%s has a method called " + - "componentDidUnmount(). But there is no such lifecycle method. " + - "Did you mean componentWillUnmount()?", - name - ) - : void 0; - var noComponentDidReceiveProps = - typeof instance.componentDidReceiveProps !== "function"; - !noComponentDidReceiveProps - ? warningWithoutStack$1( - false, - "%s has a method called " + - "componentDidReceiveProps(). But there is no such lifecycle method. " + - "If you meant to update the state in response to changing props, " + - "use componentWillReceiveProps(). If you meant to fetch data or " + - "run side-effects or mutations after React has updated the UI, use componentDidUpdate().", - name - ) - : void 0; - var noComponentWillRecieveProps = - typeof instance.componentWillRecieveProps !== "function"; - !noComponentWillRecieveProps - ? warningWithoutStack$1( - false, - "%s has a method called " + - "componentWillRecieveProps(). Did you mean componentWillReceiveProps()?", - name - ) - : void 0; - var noUnsafeComponentWillRecieveProps = - typeof instance.UNSAFE_componentWillRecieveProps !== "function"; - !noUnsafeComponentWillRecieveProps - ? warningWithoutStack$1( - false, - "%s has a method called " + - "UNSAFE_componentWillRecieveProps(). Did you mean UNSAFE_componentWillReceiveProps()?", - name - ) - : void 0; + if (typeof instance.componentDidUnmount === "function") { + error( + "%s has a method called " + + "componentDidUnmount(). But there is no such lifecycle method. " + + "Did you mean componentWillUnmount()?", + name + ); + } + + if (typeof instance.componentDidReceiveProps === "function") { + error( + "%s has a method called " + + "componentDidReceiveProps(). But there is no such lifecycle method. " + + "If you meant to update the state in response to changing props, " + + "use componentWillReceiveProps(). If you meant to fetch data or " + + "run side-effects or mutations after React has updated the UI, use componentDidUpdate().", + name + ); + } + + if (typeof instance.componentWillRecieveProps === "function") { + error( + "%s has a method called " + + "componentWillRecieveProps(). Did you mean componentWillReceiveProps()?", + name + ); + } + + if (typeof instance.UNSAFE_componentWillRecieveProps === "function") { + error( + "%s has a method called " + + "UNSAFE_componentWillRecieveProps(). Did you mean UNSAFE_componentWillReceiveProps()?", + name + ); + } + var hasMutatedProps = instance.props !== newProps; - !(instance.props === undefined || !hasMutatedProps) - ? warningWithoutStack$1( - false, - "%s(...): When calling super() in `%s`, make sure to pass " + - "up the same props that your component's constructor was passed.", - name, - name - ) - : void 0; - var noInstanceDefaultProps = !instance.defaultProps; - !noInstanceDefaultProps - ? warningWithoutStack$1( - false, - "Setting defaultProps as an instance property on %s is not supported and will be ignored." + - " Instead, define defaultProps as a static property on %s.", - name, - name - ) - : void 0; + + if (instance.props !== undefined && hasMutatedProps) { + error( + "%s(...): When calling super() in `%s`, make sure to pass " + + "up the same props that your component's constructor was passed.", + name, + name + ); + } + + if (instance.defaultProps) { + error( + "Setting defaultProps as an instance property on %s is not supported and will be ignored." + + " Instead, define defaultProps as a static property on %s.", + name, + name + ); + } if ( typeof instance.getSnapshotBeforeUpdate === "function" && @@ -8163,63 +7974,53 @@ function checkClassInstance(workInProgress, ctor, newProps) { !didWarnAboutGetSnapshotBeforeUpdateWithoutDidUpdate.has(ctor) ) { didWarnAboutGetSnapshotBeforeUpdateWithoutDidUpdate.add(ctor); - warningWithoutStack$1( - false, + + error( "%s: getSnapshotBeforeUpdate() should be used with componentDidUpdate(). " + "This component defines getSnapshotBeforeUpdate() only.", getComponentName(ctor) ); } - var noInstanceGetDerivedStateFromProps = - typeof instance.getDerivedStateFromProps !== "function"; - !noInstanceGetDerivedStateFromProps - ? warningWithoutStack$1( - false, - "%s: getDerivedStateFromProps() is defined as an instance method " + - "and will be ignored. Instead, declare it as a static method.", - name - ) - : void 0; - var noInstanceGetDerivedStateFromCatch = - typeof instance.getDerivedStateFromError !== "function"; - !noInstanceGetDerivedStateFromCatch - ? warningWithoutStack$1( - false, - "%s: getDerivedStateFromError() is defined as an instance method " + - "and will be ignored. Instead, declare it as a static method.", - name - ) - : void 0; - var noStaticGetSnapshotBeforeUpdate = - typeof ctor.getSnapshotBeforeUpdate !== "function"; - !noStaticGetSnapshotBeforeUpdate - ? warningWithoutStack$1( - false, - "%s: getSnapshotBeforeUpdate() is defined as a static method " + - "and will be ignored. Instead, declare it as an instance method.", - name - ) - : void 0; - var _state = instance.state; + if (typeof instance.getDerivedStateFromProps === "function") { + error( + "%s: getDerivedStateFromProps() is defined as an instance method " + + "and will be ignored. Instead, declare it as a static method.", + name + ); + } - if (_state && (typeof _state !== "object" || isArray$1(_state))) { - warningWithoutStack$1( - false, - "%s.state: must be set to an object or null", + if (typeof instance.getDerivedStateFromError === "function") { + error( + "%s: getDerivedStateFromError() is defined as an instance method " + + "and will be ignored. Instead, declare it as a static method.", + name + ); + } + + if (typeof ctor.getSnapshotBeforeUpdate === "function") { + error( + "%s: getSnapshotBeforeUpdate() is defined as a static method " + + "and will be ignored. Instead, declare it as an instance method.", name ); } - if (typeof instance.getChildContext === "function") { - !(typeof ctor.childContextTypes === "object") - ? warningWithoutStack$1( - false, - "%s.getChildContext(): childContextTypes must be defined in order to " + - "use getChildContext().", - name - ) - : void 0; + var _state = instance.state; + + if (_state && (typeof _state !== "object" || isArray$1(_state))) { + error("%s.state: must be set to an object or null", name); + } + + if ( + typeof instance.getChildContext === "function" && + typeof ctor.childContextTypes !== "object" + ) { + error( + "%s.getChildContext(): childContextTypes must be defined in order to " + + "use getChildContext().", + name + ); } } } @@ -8278,8 +8079,7 @@ function constructClassInstance( "}."; } - warningWithoutStack$1( - false, + error( "%s defines an invalid contextType. " + "contextType should point to the Context object returned by React.createContext().%s", getComponentName(ctor) || "Component", @@ -8323,8 +8123,8 @@ function constructClassInstance( if (!didWarnAboutUninitializedState.has(componentName)) { didWarnAboutUninitializedState.add(componentName); - warningWithoutStack$1( - false, + + error( "`%s` uses `getDerivedStateFromProps` but its initial state is " + "%s. This is not recommended. Instead, define the initial state by " + "assigning an object to `this.state` in the constructor of `%s`. " + @@ -8389,8 +8189,8 @@ function constructClassInstance( if (!didWarnAboutLegacyLifecyclesAndDerivedState.has(_componentName)) { didWarnAboutLegacyLifecyclesAndDerivedState.add(_componentName); - warningWithoutStack$1( - false, + + error( "Unsafe legacy lifecycles will not be called for components using new component APIs.\n\n" + "%s uses %s but also contains the following legacy lifecycles:%s%s%s\n\n" + "The above lifecycles should be removed. Learn more about this warning here:\n" + @@ -8432,8 +8232,7 @@ function callComponentWillMount(workInProgress, instance) { if (oldState !== instance.state) { { - warningWithoutStack$1( - false, + error( "%s.componentWillMount(): Assigning directly to this.state is " + "deprecated (except inside a component's " + "constructor). Use setState instead.", @@ -8470,8 +8269,8 @@ function callComponentWillReceiveProps( if (!didWarnAboutStateAssignmentForComponent.has(componentName)) { didWarnAboutStateAssignmentForComponent.add(componentName); - warningWithoutStack$1( - false, + + error( "%s.componentWillReceiveProps(): Assigning directly to " + "this.state is deprecated (except inside a component's " + "constructor). Use setState instead.", @@ -8498,6 +8297,7 @@ function mountClassInstance( instance.props = newProps; instance.state = workInProgress.memoizedState; instance.refs = emptyRefsObject; + initializeUpdateQueue(workInProgress); var contextType = ctor.contextType; if (typeof contextType === "object" && contextType !== null) { @@ -8515,8 +8315,8 @@ function mountClassInstance( if (!didWarnAboutDirectlyAssigningPropsToState.has(componentName)) { didWarnAboutDirectlyAssigningPropsToState.add(componentName); - warningWithoutStack$1( - false, + + error( "%s: It is not recommended to assign props directly to state " + "because updates to props won't be reflected in state. " + "In most cases, it is better to use props directly.", @@ -8540,19 +8340,8 @@ function mountClassInstance( } } - var updateQueue = workInProgress.updateQueue; - - if (updateQueue !== null) { - processUpdateQueue( - workInProgress, - updateQueue, - newProps, - instance, - renderExpirationTime - ); - instance.state = workInProgress.memoizedState; - } - + processUpdateQueue(workInProgress, newProps, instance, renderExpirationTime); + instance.state = workInProgress.memoizedState; var getDerivedStateFromProps = ctor.getDerivedStateFromProps; if (typeof getDerivedStateFromProps === "function") { @@ -8575,18 +8364,13 @@ function mountClassInstance( callComponentWillMount(workInProgress, instance); // If we had additional state updates during this life-cycle, let's // process them now. - updateQueue = workInProgress.updateQueue; - - if (updateQueue !== null) { - processUpdateQueue( - workInProgress, - updateQueue, - newProps, - instance, - renderExpirationTime - ); - instance.state = workInProgress.memoizedState; - } + processUpdateQueue( + workInProgress, + newProps, + instance, + renderExpirationTime + ); + instance.state = workInProgress.memoizedState; } if (typeof instance.componentDidMount === "function") { @@ -8645,18 +8429,8 @@ function resumeMountClassInstance( resetHasForceUpdateBeforeProcessing(); var oldState = workInProgress.memoizedState; var newState = (instance.state = oldState); - var updateQueue = workInProgress.updateQueue; - - if (updateQueue !== null) { - processUpdateQueue( - workInProgress, - updateQueue, - newProps, - instance, - renderExpirationTime - ); - newState = workInProgress.memoizedState; - } + processUpdateQueue(workInProgress, newProps, instance, renderExpirationTime); + newState = workInProgress.memoizedState; if ( oldProps === newProps && @@ -8746,6 +8520,7 @@ function updateClassInstance( renderExpirationTime ) { var instance = workInProgress.stateNode; + cloneUpdateQueue(current, workInProgress); var oldProps = workInProgress.memoizedProps; instance.props = workInProgress.type === workInProgress.elementType @@ -8789,18 +8564,8 @@ function updateClassInstance( resetHasForceUpdateBeforeProcessing(); var oldState = workInProgress.memoizedState; var newState = (instance.state = oldState); - var updateQueue = workInProgress.updateQueue; - - if (updateQueue !== null) { - processUpdateQueue( - workInProgress, - updateQueue, - newProps, - instance, - renderExpirationTime - ); - newState = workInProgress.memoizedState; - } + processUpdateQueue(workInProgress, newProps, instance, renderExpirationTime); + newState = workInProgress.memoizedState; if ( oldProps === newProps && @@ -8962,8 +8727,8 @@ var warnForMissingKey = function(child) {}; } ownerHasKeyUseWarning[currentComponentErrorInfo] = true; - warning$1( - false, + + error( "Each child in a list should have a unique " + '"key" prop. See https://fb.me/react-warning-keys for ' + "more information." @@ -8989,8 +8754,7 @@ function coerceRef(returnFiber, current$$1, element) { if (!didWarnAboutStringRefs[componentName]) { if (warnAboutStringRefs) { - warningWithoutStack$1( - false, + error( 'Component "%s" contains the string ref "%s". Support for string refs ' + "will be removed in a future major release. We recommend using " + "useRef() or createRef() instead. " + @@ -9001,8 +8765,7 @@ function coerceRef(returnFiber, current$$1, element) { getStackByFiberInDevAndProd(returnFiber) ); } else { - warningWithoutStack$1( - false, + error( 'A string ref, "%s", has been found within a strict mode tree. ' + "String refs are a source of potential bugs and should be avoided. " + "We recommend using useRef() or createRef() instead. " + @@ -9115,23 +8878,25 @@ function throwOnInvalidObjectType(returnFiber, newChild) { } function warnOnFunctionType() { - var currentComponentErrorInfo = - "Functions are not valid as a React child. This may happen if " + - "you return a Component instead of from render. " + - "Or maybe you meant to call this function rather than return it." + - getCurrentFiberStackInDev(); + { + var currentComponentErrorInfo = + "Functions are not valid as a React child. This may happen if " + + "you return a Component instead of from render. " + + "Or maybe you meant to call this function rather than return it." + + getCurrentFiberStackInDev(); - if (ownerHasFunctionTypeWarning[currentComponentErrorInfo]) { - return; - } + if (ownerHasFunctionTypeWarning[currentComponentErrorInfo]) { + return; + } - ownerHasFunctionTypeWarning[currentComponentErrorInfo] = true; - warning$1( - false, - "Functions are not valid as a React child. This may happen if " + - "you return a Component instead of from render. " + - "Or maybe you meant to call this function rather than return it." - ); + ownerHasFunctionTypeWarning[currentComponentErrorInfo] = true; + + error( + "Functions are not valid as a React child. This may happen if " + + "you return a Component instead of from render. " + + "Or maybe you meant to call this function rather than return it." + ); + } } // This wrapper function exists because I expect to clone the code in each path // to be able to optimize each path individually by branching early. This needs // a compiler or we can do it manually. Helpers that don't need this branching @@ -9269,33 +9034,51 @@ function ChildReconciler(shouldTrackSideEffects) { } function updateElement(returnFiber, current$$1, element, expirationTime) { - if ( - current$$1 !== null && - (current$$1.elementType === element.type || // Keep this check inline so it only runs on the false path: - isCompatibleFamilyForHotReloading(current$$1, element)) - ) { - // Move based on index - var existing = useFiber(current$$1, element.props, expirationTime); - existing.ref = coerceRef(returnFiber, current$$1, element); - existing.return = returnFiber; + if (current$$1 !== null) { + if ( + current$$1.elementType === element.type || // Keep this check inline so it only runs on the false path: + isCompatibleFamilyForHotReloading(current$$1, element) + ) { + // Move based on index + var existing = useFiber(current$$1, element.props, expirationTime); + existing.ref = coerceRef(returnFiber, current$$1, element); + existing.return = returnFiber; - { - existing._debugSource = element._source; - existing._debugOwner = element._owner; + { + existing._debugSource = element._source; + existing._debugOwner = element._owner; + } + + return existing; + } else if ( + enableChunksAPI && + current$$1.tag === Chunk && + element.type.$$typeof === REACT_CHUNK_TYPE && + element.type.render === current$$1.type.render + ) { + // Same as above but also update the .type field. + var _existing = useFiber(current$$1, element.props, expirationTime); + + _existing.return = returnFiber; + _existing.type = element.type; + + { + _existing._debugSource = element._source; + _existing._debugOwner = element._owner; + } + + return _existing; } + } // Insert - return existing; - } else { - // Insert - var created = createFiberFromElement( - element, - returnFiber.mode, - expirationTime - ); - created.ref = coerceRef(returnFiber, current$$1, element); - created.return = returnFiber; - return created; - } + var created = createFiberFromElement( + element, + returnFiber.mode, + expirationTime + ); + created.ref = coerceRef(returnFiber, current$$1, element); + created.return = returnFiber; + return created; } function updatePortal(returnFiber, current$$1, portal, expirationTime) { @@ -9613,8 +9396,7 @@ function ChildReconciler(shouldTrackSideEffects) { break; } - warning$1( - false, + error( "Encountered two children with the same key, `%s`. " + "Keys should be unique so that components maintain their identity " + "across updates. Non-unique keys may cause children to be " + @@ -9622,6 +9404,7 @@ function ChildReconciler(shouldTrackSideEffects) { "could change in a future version.", key ); + break; default: @@ -9827,28 +9610,28 @@ function ChildReconciler(shouldTrackSideEffects) { typeof Symbol === "function" && // $FlowFixMe Flow doesn't know about toStringTag newChildrenIterable[Symbol.toStringTag] === "Generator" ) { - !didWarnAboutGenerators - ? warning$1( - false, - "Using Generators as children is unsupported and will likely yield " + - "unexpected results because enumerating a generator mutates it. " + - "You may convert it to an array with `Array.from()` or the " + - "`[...spread]` operator before rendering. Keep in mind " + - "you might need to polyfill these features for older browsers." - ) - : void 0; + if (!didWarnAboutGenerators) { + error( + "Using Generators as children is unsupported and will likely yield " + + "unexpected results because enumerating a generator mutates it. " + + "You may convert it to an array with `Array.from()` or the " + + "`[...spread]` operator before rendering. Keep in mind " + + "you might need to polyfill these features for older browsers." + ); + } + didWarnAboutGenerators = true; } // Warn about using Maps as children if (newChildrenIterable.entries === iteratorFn) { - !didWarnAboutMaps - ? warning$1( - false, - "Using Maps as children is unsupported and will likely yield " + - "unexpected results. Convert it to a sequence/iterable of keyed " + - "ReactElements instead." - ) - : void 0; + if (!didWarnAboutMaps) { + error( + "Using Maps as children is unsupported and will likely yield " + + "unexpected results. Convert it to a sequence/iterable of keyed " + + "ReactElements instead." + ); + } + didWarnAboutMaps = true; } // First, validate keys. // We'll get a different iterator later for the main pass. @@ -10056,33 +9839,79 @@ function ChildReconciler(shouldTrackSideEffects) { // TODO: If key === null and child.key === null, then this only applies to // the first item in the list. if (child.key === key) { - if ( - child.tag === Fragment - ? element.type === REACT_FRAGMENT_TYPE - : child.elementType === element.type || // Keep this check inline so it only runs on the false path: + switch (child.tag) { + case Fragment: { + if (element.type === REACT_FRAGMENT_TYPE) { + deleteRemainingChildren(returnFiber, child.sibling); + var existing = useFiber( + child, + element.props.children, + expirationTime + ); + existing.return = returnFiber; + + { + existing._debugSource = element._source; + existing._debugOwner = element._owner; + } + + return existing; + } + + break; + } + + case Chunk: + if (enableChunksAPI) { + if ( + element.type.$$typeof === REACT_CHUNK_TYPE && + element.type.render === child.type.render + ) { + deleteRemainingChildren(returnFiber, child.sibling); + + var _existing2 = useFiber(child, element.props, expirationTime); + + _existing2.type = element.type; + _existing2.return = returnFiber; + + { + _existing2._debugSource = element._source; + _existing2._debugOwner = element._owner; + } + + return _existing2; + } + } + + // We intentionally fallthrough here if enableChunksAPI is not on. + // eslint-disable-next-lined no-fallthrough + + default: { + if ( + child.elementType === element.type || // Keep this check inline so it only runs on the false path: isCompatibleFamilyForHotReloading(child, element) - ) { - deleteRemainingChildren(returnFiber, child.sibling); - var existing = useFiber( - child, - element.type === REACT_FRAGMENT_TYPE - ? element.props.children - : element.props, - expirationTime - ); - existing.ref = coerceRef(returnFiber, child, element); - existing.return = returnFiber; + ) { + deleteRemainingChildren(returnFiber, child.sibling); - { - existing._debugSource = element._source; - existing._debugOwner = element._owner; + var _existing3 = useFiber(child, element.props, expirationTime); + + _existing3.ref = coerceRef(returnFiber, child, element); + _existing3.return = returnFiber; + + { + _existing3._debugSource = element._source; + _existing3._debugOwner = element._owner; + } + + return _existing3; + } + + break; } + } // Didn't match. - return existing; - } else { - deleteRemainingChildren(returnFiber, child); - break; - } + deleteRemainingChildren(returnFiber, child); + break; } else { deleteChild(returnFiber, child); } @@ -10577,7 +10406,7 @@ function mountEventResponder( } } - mountResponderInstance( + DEPRECATED_mountResponderInstance( responder, responderInstance, responderProps, @@ -10613,8 +10442,7 @@ function updateEventListener( if (visistedResponders.has(responder)) { // show warning { - warning$1( - false, + error( 'Duplicate event responder "%s" found in event listeners. ' + "Event listeners passed to elements cannot use the same event responder more than once.", responder.displayName @@ -10643,7 +10471,11 @@ function updateEventListener( } } -function updateEventListeners(listeners, fiber, rootContainerInstance) { +function updateDeprecatedEventListeners( + listeners, + fiber, + rootContainerInstance +) { var visistedResponders = new Set(); var dependencies = fiber.dependencies; @@ -10659,7 +10491,7 @@ function updateEventListeners(listeners, fiber, rootContainerInstance) { var respondersMap = dependencies.responders; if (respondersMap === null) { - respondersMap = new Map(); + dependencies.responders = respondersMap = new Map(); } if (isArray$2(listeners)) { @@ -10697,7 +10529,7 @@ function updateEventListeners(listeners, fiber, rootContainerInstance) { if (!visistedResponders.has(mountedResponder)) { var responderInstance = _respondersMap.get(mountedResponder); - unmountResponderInstance(responderInstance); + DEPRECATED_unmountResponderInstance(responderInstance); _respondersMap.delete(mountedResponder); } @@ -10705,7 +10537,7 @@ function updateEventListeners(listeners, fiber, rootContainerInstance) { } } } -function createResponderListener(responder, props) { +function createDeprecatedResponderListener(responder, props) { var eventResponderListener = { responder: responder, props: props @@ -10717,6 +10549,24 @@ function createResponderListener(responder, props) { return eventResponderListener; } +function unmountDeprecatedResponderListeners(fiber) { + var dependencies = fiber.dependencies; + + if (dependencies !== null) { + var respondersMap = dependencies.responders; + + if (respondersMap !== null) { + var responderInstances = Array.from(respondersMap.values()); + + for (var i = 0, length = responderInstances.length; i < length; i++) { + var responderInstance = responderInstances[i]; + DEPRECATED_unmountResponderInstance(responderInstance); + } + + dependencies.responders = null; + } + } +} var NoEffect$1 = /* */ @@ -10761,13 +10611,7 @@ var currentlyRenderingFiber$1 = null; // Hooks are stored as a linked list on th // work-in-progress fiber. var currentHook = null; -var nextCurrentHook = null; -var firstWorkInProgressHook = null; -var workInProgressHook = null; -var nextWorkInProgressHook = null; -var remainingExpirationTime = NoWork; -var componentUpdateQueue = null; -var sideEffectTag = 0; // Updates scheduled during render will trigger an immediate re-render at the +var workInProgressHook = null; // Updates scheduled during render will trigger an immediate re-render at the // end of the current pass. We can't store these updates on the normal queue, // because if the work is aborted, they should be discarded. Because this is // a relatively rare case, we also don't want to add an additional field to @@ -10825,8 +10669,7 @@ function checkDepsAreArrayDev(deps) { if (deps !== undefined && deps !== null && !Array.isArray(deps)) { // Verify deps, but only on mount to avoid extra checks. // It's unlikely their type would change as usually you define them inline. - warning$1( - false, + error( "%s received a final argument that is not an array (instead, received `%s`). When " + "specified, the final argument must be an array.", currentHookNameInDev, @@ -10862,8 +10705,7 @@ function warnOnHookMismatchInDev(currentHookName) { table += row; } - warning$1( - false, + error( "React has detected a change in the order of Hooks called by %s. " + "This will lead to bugs and errors if not fixed. " + "For more information, read the Rules of Hooks: https://fb.me/rules-of-hooks\n\n" + @@ -10897,8 +10739,7 @@ function areHookInputsEqual(nextDeps, prevDeps) { if (prevDeps === null) { { - warning$1( - false, + error( "%s received a final argument during this render, but not during " + "the previous render. Even though the final argument is optional, " + "its type cannot change between renders.", @@ -10913,8 +10754,7 @@ function areHookInputsEqual(nextDeps, prevDeps) { // Don't bother comparing lengths in prod because these arrays should be // passed inline. if (nextDeps.length !== prevDeps.length) { - warning$1( - false, + error( "The final argument passed to %s changed size between renders. The " + "order and size of this array must remain constant.\n\n" + "Previous: %s\n" + @@ -10942,12 +10782,11 @@ function renderWithHooks( workInProgress, Component, props, - refOrContext, + secondArg, nextRenderExpirationTime ) { renderExpirationTime$1 = nextRenderExpirationTime; currentlyRenderingFiber$1 = workInProgress; - nextCurrentHook = current !== null ? current.memoizedState : null; { hookTypesDev = current !== null ? current._debugHookTypes : null; @@ -10955,24 +10794,25 @@ function renderWithHooks( ignorePreviousDependencies = current !== null && current.type !== workInProgress.type; - } // The following should have already been reset + } + + workInProgress.memoizedState = null; + workInProgress.updateQueue = null; + workInProgress.expirationTime = NoWork; // The following should have already been reset // currentHook = null; // workInProgressHook = null; - // remainingExpirationTime = NoWork; - // componentUpdateQueue = null; // didScheduleRenderPhaseUpdate = false; // renderPhaseUpdates = null; // numberOfReRenders = 0; - // sideEffectTag = 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 nextCurrentHook === null. + // 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) - // Using nextCurrentHook to differentiate between mount/update only works if at least one stateful hook is used. + // Using memoizedState to differentiate between mount/update only works if at least one stateful hook is used. // Non-stateful hooks (e.g. context) don't get added to memoizedState, - // so nextCurrentHook would be null during updates and mounts. + // so memoizedState would be null during updates and mounts. { - if (nextCurrentHook !== null) { + if (current !== null && current.memoizedState !== null) { ReactCurrentDispatcher$1.current = HooksDispatcherOnUpdateInDEV; } else if (hookTypesDev !== null) { // This dispatcher handles an edge case where a component is updating, @@ -10986,7 +10826,7 @@ function renderWithHooks( } } - var children = Component(props, refOrContext); + var children = Component(props, secondArg); if (didScheduleRenderPhaseUpdate) { do { @@ -10999,11 +10839,9 @@ function renderWithHooks( ignorePreviousDependencies = false; } // Start over from the beginning of the list - nextCurrentHook = current !== null ? current.memoizedState : null; - nextWorkInProgressHook = firstWorkInProgressHook; currentHook = null; workInProgressHook = null; - componentUpdateQueue = null; + workInProgress.updateQueue = null; { // Also validate hook order for cascading updates. @@ -11011,7 +10849,7 @@ function renderWithHooks( } ReactCurrentDispatcher$1.current = HooksDispatcherOnUpdateInDEV; - children = Component(props, refOrContext); + children = Component(props, secondArg); } while (didScheduleRenderPhaseUpdate); renderPhaseUpdates = null; @@ -11020,14 +10858,9 @@ function renderWithHooks( // at the beginning of the render phase and there's no re-entrancy. ReactCurrentDispatcher$1.current = ContextOnlyDispatcher; - var renderedWork = currentlyRenderingFiber$1; - renderedWork.memoizedState = firstWorkInProgressHook; - renderedWork.expirationTime = remainingExpirationTime; - renderedWork.updateQueue = componentUpdateQueue; - renderedWork.effectTag |= sideEffectTag; { - renderedWork._debugHookTypes = hookTypesDev; + workInProgress._debugHookTypes = hookTypesDev; } // This check uses currentHook so that it works the same in DEV and prod bundles. // hookTypesDev could catch more cases (e.g. context) but only in DEV bundles. @@ -11035,20 +10868,13 @@ function renderWithHooks( renderExpirationTime$1 = NoWork; currentlyRenderingFiber$1 = null; currentHook = null; - nextCurrentHook = null; - firstWorkInProgressHook = null; workInProgressHook = null; - nextWorkInProgressHook = null; { currentHookNameInDev = null; hookTypesDev = null; hookTypesUpdateIndexDev = -1; - } - - remainingExpirationTime = NoWork; - componentUpdateQueue = null; - sideEffectTag = 0; // These were reset above + } // These were reset above // didScheduleRenderPhaseUpdate = false; // renderPhaseUpdates = null; // numberOfReRenders = 0; @@ -11079,10 +10905,7 @@ function resetHooks() { renderExpirationTime$1 = NoWork; currentlyRenderingFiber$1 = null; currentHook = null; - nextCurrentHook = null; - firstWorkInProgressHook = null; workInProgressHook = null; - nextWorkInProgressHook = null; { hookTypesDev = null; @@ -11090,9 +10913,6 @@ function resetHooks() { currentHookNameInDev = null; } - remainingExpirationTime = NoWork; - componentUpdateQueue = null; - sideEffectTag = 0; didScheduleRenderPhaseUpdate = false; renderPhaseUpdates = null; numberOfReRenders = 0; @@ -11102,14 +10922,14 @@ function mountWorkInProgressHook() { var hook = { memoizedState: null, baseState: null, + baseQueue: null, queue: null, - baseUpdate: null, next: null }; if (workInProgressHook === null) { // This is the first hook in the list - firstWorkInProgressHook = workInProgressHook = hook; + currentlyRenderingFiber$1.memoizedState = workInProgressHook = hook; } else { // Append to the end of the list workInProgressHook = workInProgressHook.next = hook; @@ -11124,12 +10944,33 @@ function updateWorkInProgressHook() { // clone, or a work-in-progress hook from a previous render pass that we can // use as a base. When we reach the end of the base list, we must switch to // the dispatcher used for mounts. + var nextCurrentHook; + + if (currentHook === null) { + var current = currentlyRenderingFiber$1.alternate; + + if (current !== null) { + nextCurrentHook = current.memoizedState; + } else { + nextCurrentHook = null; + } + } else { + nextCurrentHook = currentHook.next; + } + + var nextWorkInProgressHook; + + if (workInProgressHook === null) { + nextWorkInProgressHook = currentlyRenderingFiber$1.memoizedState; + } else { + nextWorkInProgressHook = workInProgressHook.next; + } + if (nextWorkInProgressHook !== null) { // There's already a work-in-progress. Reuse it. workInProgressHook = nextWorkInProgressHook; nextWorkInProgressHook = workInProgressHook.next; currentHook = nextCurrentHook; - nextCurrentHook = currentHook !== null ? currentHook.next : null; } else { // Clone from the current hook. if (!(nextCurrentHook !== null)) { @@ -11140,20 +10981,18 @@ function updateWorkInProgressHook() { var newHook = { memoizedState: currentHook.memoizedState, baseState: currentHook.baseState, + baseQueue: currentHook.baseQueue, queue: currentHook.queue, - baseUpdate: currentHook.baseUpdate, next: null }; if (workInProgressHook === null) { // This is the first hook in the list. - workInProgressHook = firstWorkInProgressHook = newHook; + currentlyRenderingFiber$1.memoizedState = workInProgressHook = newHook; } else { // Append to the end of the list. workInProgressHook = workInProgressHook.next = newHook; } - - nextCurrentHook = currentHook.next; } return workInProgressHook; @@ -11181,13 +11020,13 @@ function mountReducer(reducer, initialArg, init) { hook.memoizedState = hook.baseState = initialState; var queue = (hook.queue = { - last: null, + pending: null, dispatch: null, lastRenderedReducer: reducer, lastRenderedState: initialState }); var dispatch = (queue.dispatch = dispatchAction.bind( - null, // Flow doesn't know this is non-null, but we do. + null, currentlyRenderingFiber$1, queue )); @@ -11239,7 +11078,7 @@ function updateReducer(reducer, initialArg, init) { // TODO: Not sure if this is the desired semantics, but it's what we // do for gDSFP. I can't remember why. - if (hook.baseUpdate === queue.last) { + if (hook.baseQueue === null) { hook.baseState = newState; } @@ -11249,35 +11088,37 @@ function updateReducer(reducer, initialArg, init) { } return [hook.memoizedState, _dispatch]; - } // The last update in the entire queue + } - var last = queue.last; // The last update that is part of the base state. + var current = currentHook; // The last rebase update that is NOT part of the base state. - var baseUpdate = hook.baseUpdate; - var baseState = hook.baseState; // Find the first unprocessed update. + var baseQueue = current.baseQueue; // The last pending update that hasn't been processed yet. - var first; + var pendingQueue = queue.pending; - if (baseUpdate !== null) { - if (last !== null) { - // For the first update, the queue is a circular linked list where - // `queue.last.next = queue.first`. Once the first update commits, and - // the `baseUpdate` is no longer empty, we can unravel the list. - last.next = null; + if (pendingQueue !== null) { + // We have new updates that haven't been processed yet. + // We'll add them to the base queue. + if (baseQueue !== null) { + // Merge the pending queue and the base queue. + var baseFirst = baseQueue.next; + var pendingFirst = pendingQueue.next; + baseQueue.next = pendingFirst; + pendingQueue.next = baseFirst; } - first = baseUpdate.next; - } else { - first = last !== null ? last.next : null; + current.baseQueue = baseQueue = pendingQueue; + queue.pending = null; } - if (first !== null) { - var _newState = baseState; + if (baseQueue !== null) { + // We have a queue to process. + var first = baseQueue.next; + var _newState = current.baseState; var newBaseState = null; - var newBaseUpdate = null; - var prevUpdate = baseUpdate; + var newBaseQueueFirst = null; + var newBaseQueueLast = null; var _update = first; - var didSkip = false; do { var updateExpirationTime = _update.expirationTime; @@ -11286,24 +11127,46 @@ function updateReducer(reducer, initialArg, init) { // Priority is insufficient. Skip this update. If this is the first // skipped update, the previous update/state is the new base // update/state. - if (!didSkip) { - didSkip = true; - newBaseUpdate = prevUpdate; + var clone = { + expirationTime: _update.expirationTime, + suspenseConfig: _update.suspenseConfig, + action: _update.action, + eagerReducer: _update.eagerReducer, + eagerState: _update.eagerState, + next: null + }; + + if (newBaseQueueLast === null) { + newBaseQueueFirst = newBaseQueueLast = clone; newBaseState = _newState; + } else { + newBaseQueueLast = newBaseQueueLast.next = clone; } // Update the remaining priority in the queue. - if (updateExpirationTime > remainingExpirationTime) { - remainingExpirationTime = updateExpirationTime; - markUnprocessedUpdateTime(remainingExpirationTime); + if (updateExpirationTime > currentlyRenderingFiber$1.expirationTime) { + currentlyRenderingFiber$1.expirationTime = updateExpirationTime; + markUnprocessedUpdateTime(updateExpirationTime); } } else { // This update does have sufficient priority. - // Mark the event time of this update as relevant to this render pass. + if (newBaseQueueLast !== null) { + var _clone = { + expirationTime: Sync, + // This update is going to be committed so we never want uncommit it. + suspenseConfig: _update.suspenseConfig, + action: _update.action, + eagerReducer: _update.eagerReducer, + eagerState: _update.eagerState, + next: null + }; + newBaseQueueLast = newBaseQueueLast.next = _clone; + } // Mark the event time of this update as relevant to this render pass. // TODO: This should ideally use the true event time of this update rather than // its priority which is a derived and not reverseable value. // TODO: We should skip this update if it was already committed but currently // we have no way of detecting the difference between a committed and suspended // update here. + markRenderEventTimeAndConfig( updateExpirationTime, _update.suspenseConfig @@ -11319,13 +11182,13 @@ function updateReducer(reducer, initialArg, init) { } } - prevUpdate = _update; _update = _update.next; } while (_update !== null && _update !== first); - if (!didSkip) { - newBaseUpdate = prevUpdate; + if (newBaseQueueLast === null) { newBaseState = _newState; + } else { + newBaseQueueLast.next = newBaseQueueFirst; } // Mark that the fiber performed work, but only if the new state is // different from the current state. @@ -11334,8 +11197,8 @@ function updateReducer(reducer, initialArg, init) { } hook.memoizedState = _newState; - hook.baseUpdate = newBaseUpdate; hook.baseState = newBaseState; + hook.baseQueue = newBaseQueueLast; queue.lastRenderedState = _newState; } @@ -11352,13 +11215,13 @@ function mountState(initialState) { hook.memoizedState = hook.baseState = initialState; var queue = (hook.queue = { - last: null, + pending: null, dispatch: null, lastRenderedReducer: basicStateReducer, lastRenderedState: initialState }); var dispatch = (queue.dispatch = dispatchAction.bind( - null, // Flow doesn't know this is non-null, but we do. + null, currentlyRenderingFiber$1, queue )); @@ -11378,9 +11241,11 @@ function pushEffect(tag, create, destroy, deps) { // Circular next: null }; + var componentUpdateQueue = currentlyRenderingFiber$1.updateQueue; if (componentUpdateQueue === null) { componentUpdateQueue = createFunctionComponentUpdateQueue(); + currentlyRenderingFiber$1.updateQueue = componentUpdateQueue; componentUpdateQueue.lastEffect = effect.next = effect; } else { var lastEffect = componentUpdateQueue.lastEffect; @@ -11420,7 +11285,7 @@ function updateRef(initialValue) { function mountEffectImpl(fiberEffectTag, hookEffectTag, create, deps) { var hook = mountWorkInProgressHook(); var nextDeps = deps === undefined ? null : deps; - sideEffectTag |= fiberEffectTag; + currentlyRenderingFiber$1.effectTag |= fiberEffectTag; hook.memoizedState = pushEffect(hookEffectTag, create, undefined, nextDeps); } @@ -11443,7 +11308,7 @@ function updateEffectImpl(fiberEffectTag, hookEffectTag, create, deps) { } } - sideEffectTag |= fiberEffectTag; + currentlyRenderingFiber$1.effectTag |= fiberEffectTag; hook.memoizedState = pushEffect(hookEffectTag, create, destroy, nextDeps); } @@ -11501,14 +11366,13 @@ function imperativeHandleEffect(create, ref) { var refObject = ref; { - !refObject.hasOwnProperty("current") - ? warning$1( - false, - "Expected useImperativeHandle() first argument to either be a " + - "ref callback or React.createRef() object. Instead received: %s.", - "an object with keys {" + Object.keys(refObject).join(", ") + "}" - ) - : void 0; + if (!refObject.hasOwnProperty("current")) { + error( + "Expected useImperativeHandle() first argument to either be a " + + "ref callback or React.createRef() object. Instead received: %s.", + "an object with keys {" + Object.keys(refObject).join(", ") + "}" + ); + } } var _inst2 = create(); @@ -11522,14 +11386,13 @@ function imperativeHandleEffect(create, ref) { function mountImperativeHandle(ref, create, deps) { { - !(typeof create === "function") - ? warning$1( - false, - "Expected useImperativeHandle() second argument to be a function " + - "that creates a handle. Instead received: %s.", - create !== null ? typeof create : "null" - ) - : void 0; + if (typeof create !== "function") { + error( + "Expected useImperativeHandle() second argument to be a function " + + "that creates a handle. Instead received: %s.", + create !== null ? typeof create : "null" + ); + } } // TODO: If deps are provided, should we skip comparing the ref itself? var effectDeps = @@ -11544,14 +11407,13 @@ function mountImperativeHandle(ref, create, deps) { function updateImperativeHandle(ref, create, deps) { { - !(typeof create === "function") - ? warning$1( - false, - "Expected useImperativeHandle() second argument to be a function " + - "that creates a handle. Instead received: %s.", - create !== null ? typeof create : "null" - ) - : void 0; + if (typeof create !== "function") { + error( + "Expected useImperativeHandle() second argument to be a function " + + "that creates a handle. Instead received: %s.", + create !== null ? typeof create : "null" + ); + } } // TODO: If deps are provided, should we skip comparing the ref itself? var effectDeps = @@ -11634,17 +11496,14 @@ function mountDeferredValue(value, config) { mountEffect( function() { - Scheduler.unstable_next(function() { - var previousConfig = ReactCurrentBatchConfig$1.suspense; - ReactCurrentBatchConfig$1.suspense = - config === undefined ? null : config; + var previousConfig = ReactCurrentBatchConfig$1.suspense; + ReactCurrentBatchConfig$1.suspense = config === undefined ? null : config; - try { - setValue(value); - } finally { - ReactCurrentBatchConfig$1.suspense = previousConfig; - } - }); + try { + setValue(value); + } finally { + ReactCurrentBatchConfig$1.suspense = previousConfig; + } }, [value, config] ); @@ -11658,47 +11517,54 @@ function updateDeferredValue(value, config) { updateEffect( function() { - Scheduler.unstable_next(function() { - var previousConfig = ReactCurrentBatchConfig$1.suspense; - ReactCurrentBatchConfig$1.suspense = - config === undefined ? null : config; + var previousConfig = ReactCurrentBatchConfig$1.suspense; + ReactCurrentBatchConfig$1.suspense = config === undefined ? null : config; - try { - setValue(value); - } finally { - ReactCurrentBatchConfig$1.suspense = previousConfig; - } - }); + try { + setValue(value); + } finally { + ReactCurrentBatchConfig$1.suspense = previousConfig; + } }, [value, config] ); return prevValue; } +function startTransition(setPending, config, callback) { + var priorityLevel = getCurrentPriorityLevel(); + runWithPriority( + priorityLevel < UserBlockingPriority ? UserBlockingPriority : priorityLevel, + function() { + setPending(true); + } + ); + runWithPriority( + priorityLevel > NormalPriority ? NormalPriority : priorityLevel, + function() { + var previousConfig = ReactCurrentBatchConfig$1.suspense; + ReactCurrentBatchConfig$1.suspense = config === undefined ? null : config; + + try { + setPending(false); + callback(); + } finally { + ReactCurrentBatchConfig$1.suspense = previousConfig; + } + } + ); +} + function mountTransition(config) { var _mountState2 = mountState(false), isPending = _mountState2[0], setPending = _mountState2[1]; - var startTransition = mountCallback( - function(callback) { - setPending(true); - Scheduler.unstable_next(function() { - var previousConfig = ReactCurrentBatchConfig$1.suspense; - ReactCurrentBatchConfig$1.suspense = - config === undefined ? null : config; - - try { - setPending(false); - callback(); - } finally { - ReactCurrentBatchConfig$1.suspense = previousConfig; - } - }); - }, - [config, isPending] - ); - return [startTransition, isPending]; + var start = mountCallback(startTransition.bind(null, setPending, config), [ + setPending, + config + ]); + return [start, isPending]; } function updateTransition(config) { @@ -11706,25 +11572,11 @@ function updateTransition(config) { isPending = _updateState2[0], setPending = _updateState2[1]; - var startTransition = updateCallback( - function(callback) { - setPending(true); - Scheduler.unstable_next(function() { - var previousConfig = ReactCurrentBatchConfig$1.suspense; - ReactCurrentBatchConfig$1.suspense = - config === undefined ? null : config; - - try { - setPending(false); - callback(); - } finally { - ReactCurrentBatchConfig$1.suspense = previousConfig; - } - }); - }, - [config, isPending] - ); - return [startTransition, isPending]; + var start = updateCallback(startTransition.bind(null, setPending, config), [ + setPending, + config + ]); + return [start, isPending]; } function dispatchAction(fiber, queue, action) { @@ -11735,14 +11587,13 @@ function dispatchAction(fiber, queue, action) { } { - !(typeof arguments[3] !== "function") - ? warning$1( - false, - "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()." - ) - : void 0; + 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()." + ); + } } var alternate = fiber.alternate; @@ -11807,23 +11658,17 @@ function dispatchAction(fiber, queue, action) { _update2.priority = getCurrentPriorityLevel(); } // Append the update to the end of the list. - var last = queue.last; + var pending = queue.pending; - if (last === null) { + if (pending === null) { // This is the first update. Create a circular list. _update2.next = _update2; } else { - var first = last.next; - - if (first !== null) { - // Still circular. - _update2.next = first; - } - - last.next = _update2; + _update2.next = pending.next; + pending.next = _update2; } - queue.last = _update2; + queue.pending = _update2; if ( fiber.expirationTime === NoWork && @@ -11859,7 +11704,7 @@ function dispatchAction(fiber, queue, action) { // time the reducer has changed. return; } - } catch (error) { + } catch (error$$1) { // Suppress the error. It will throw again in the render phase. } finally { { @@ -11905,8 +11750,7 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null; { var warnInvalidContextAccess = function() { - warning$1( - false, + 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 " + @@ -11915,8 +11759,7 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null; }; var warnInvalidHookAccess = function() { - warning$1( - false, + error( "Do not call Hooks inside useEffect(...), useMemo(...), or other built-in Hooks. " + "You can only call Hooks at the top level of your React function. " + "For more information, see " + @@ -12007,7 +11850,7 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null; useResponder: function(responder, props) { currentHookNameInDev = "useResponder"; mountHookTypesDev(); - return createResponderListener(responder, props); + return createDeprecatedResponderListener(responder, props); }, useDeferredValue: function(value, config) { currentHookNameInDev = "useDeferredValue"; @@ -12098,7 +11941,7 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null; useResponder: function(responder, props) { currentHookNameInDev = "useResponder"; updateHookTypesDev(); - return createResponderListener(responder, props); + return createDeprecatedResponderListener(responder, props); }, useDeferredValue: function(value, config) { currentHookNameInDev = "useDeferredValue"; @@ -12189,7 +12032,7 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null; useResponder: function(responder, props) { currentHookNameInDev = "useResponder"; updateHookTypesDev(); - return createResponderListener(responder, props); + return createDeprecatedResponderListener(responder, props); }, useDeferredValue: function(value, config) { currentHookNameInDev = "useDeferredValue"; @@ -12292,7 +12135,7 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null; currentHookNameInDev = "useResponder"; warnInvalidHookAccess(); mountHookTypesDev(); - return createResponderListener(responder, props); + return createDeprecatedResponderListener(responder, props); }, useDeferredValue: function(value, config) { currentHookNameInDev = "useDeferredValue"; @@ -12397,7 +12240,7 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null; currentHookNameInDev = "useResponder"; warnInvalidHookAccess(); updateHookTypesDev(); - return createResponderListener(responder, props); + return createDeprecatedResponderListener(responder, props); }, useDeferredValue: function(value, config) { currentHookNameInDev = "useDeferredValue"; @@ -12477,12 +12320,11 @@ var isHydrating = false; function warnIfHydrating() { { - !!isHydrating - ? warning$1( - false, - "We should not be hydrating here. This is a bug in React. Please file a bug." - ) - : void 0; + if (isHydrating) { + error( + "We should not be hydrating here. This is a bug in React. Please file a bug." + ); + } } } @@ -13009,8 +12851,8 @@ function forceUnmountCurrentAndReconcile( renderExpirationTime ); // 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 their - // identity matches. + // the effect of remounting all children regardless of whether their + // identities match. workInProgress.child = reconcileChildFibers( workInProgress, @@ -13270,7 +13112,7 @@ function updateSimpleMemoComponent( if ( shallowEqual(prevProps, nextProps) && - current$$1.ref === workInProgress.ref && // Prevent bailout if the implementation changed due to hot reload: + current$$1.ref === workInProgress.ref && // Prevent bailout if the implementation changed due to hot reload. workInProgress.type === current$$1.type ) { didReceiveUpdate = false; @@ -13430,6 +13272,73 @@ function updateFunctionComponent( return workInProgress.child; } +function updateChunk( + current$$1, + workInProgress, + chunk, + nextProps, + renderExpirationTime +) { + // 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. + var render = chunk.render; + var data = chunk.query(); // The rest is a fork of updateFunctionComponent + + var nextChildren; + prepareToReadContext(workInProgress, renderExpirationTime); + + { + ReactCurrentOwner$3.current = workInProgress; + setCurrentPhase("render"); + nextChildren = renderWithHooks( + current$$1, + workInProgress, + render, + nextProps, + data, + renderExpirationTime + ); + + if ( + debugRenderPhaseSideEffectsForStrictMode && + workInProgress.mode & StrictMode + ) { + // Only double-render components with Hooks + if (workInProgress.memoizedState !== null) { + nextChildren = renderWithHooks( + current$$1, + workInProgress, + render, + nextProps, + data, + renderExpirationTime + ); + } + } + + setCurrentPhase(null); + } + + if (current$$1 !== null && !didReceiveUpdate) { + bailoutHooks(current$$1, workInProgress, renderExpirationTime); + return bailoutOnAlreadyFinishedWork( + current$$1, + workInProgress, + renderExpirationTime + ); + } // React DevTools reads this flag. + + workInProgress.effectTag |= PerformedWork; + reconcileChildren( + current$$1, + workInProgress, + nextChildren, + renderExpirationTime + ); + return workInProgress.child; +} + function updateClassComponent( current$$1, workInProgress, @@ -13472,9 +13381,9 @@ function updateClassComponent( if (instance === null) { if (current$$1 !== null) { - // An class component without an instance only mounts if it suspended - // inside a non- concurrent tree, in an inconsistent state. We want to - // tree it like a new mount, even though an empty version of it already + // 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$$1.alternate = null; workInProgress.alternate = null; // Since this is conceptually a new fiber, schedule a Placement effect @@ -13526,14 +13435,14 @@ function updateClassComponent( var inst = workInProgress.stateNode; if (inst.props !== nextProps) { - !didWarnAboutReassigningProps - ? warning$1( - false, - "It looks like %s is reassigning its own `this.props` while rendering. " + - "This is not supported and can lead to confusing bugs.", - getComponentName(workInProgress.type) || "a component" - ) - : void 0; + 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.", + getComponentName(workInProgress.type) || "a component" + ); + } + didWarnAboutReassigningProps = true; } } @@ -13575,7 +13484,7 @@ function finishClassComponent( didCaptureError && typeof Component.getDerivedStateFromError !== "function" ) { - // If we captured an error, but getDerivedStateFrom catch is not defined, + // 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. @@ -13654,7 +13563,7 @@ function updateHostRoot(current$$1, workInProgress, renderExpirationTime) { pushHostRootContext(workInProgress); var updateQueue = workInProgress.updateQueue; - if (!(updateQueue !== null)) { + if (!(current$$1 !== 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." ); @@ -13663,13 +13572,8 @@ function updateHostRoot(current$$1, workInProgress, renderExpirationTime) { var nextProps = workInProgress.pendingProps; var prevState = workInProgress.memoizedState; var prevChildren = prevState !== null ? prevState.element : null; - processUpdateQueue( - workInProgress, - updateQueue, - nextProps, - null, - renderExpirationTime - ); + cloneUpdateQueue(current$$1, workInProgress); + processUpdateQueue(workInProgress, nextProps, null, renderExpirationTime); var nextState = workInProgress.memoizedState; // Caution: React DevTools currently depends on this property // being called "element". @@ -13743,7 +13647,7 @@ function updateHostComponent(current$$1, workInProgress, renderExpirationTime) { if (isDirectTextChild) { // We special case a direct text child of a host node. This is a common // case. We won't handle it as a reified child. We will instead handle - // this in the host environment that also have access to this prop. That + // this in the host environment that also has access to this prop. That // avoids allocating another HostText fiber and traversing it. nextChildren = null; } else if (prevProps !== null && shouldSetTextContent(type, prevProps)) { @@ -13793,7 +13697,7 @@ function mountLazyComponent( renderExpirationTime ) { if (_current !== null) { - // An lazy component only mounts if it suspended inside a non- + // 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. @@ -13831,7 +13735,7 @@ function mountLazyComponent( resolvedProps, renderExpirationTime ); - break; + return child; } case ClassComponent: { @@ -13848,7 +13752,7 @@ function mountLazyComponent( resolvedProps, renderExpirationTime ); - break; + return child; } case ForwardRef: { @@ -13865,7 +13769,7 @@ function mountLazyComponent( resolvedProps, renderExpirationTime ); - break; + return child; } case MemoComponent: { @@ -13893,36 +13797,48 @@ function mountLazyComponent( updateExpirationTime, renderExpirationTime ); - break; + return child; } - default: { - 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 Error( - "Element type is invalid. Received a promise that resolves to: " + - Component + - ". Lazy element type must resolve to a class or function." + - hint + case Chunk: { + if (enableChunksAPI) { + // TODO: Resolve for Hot Reloading. + child = updateChunk( + null, + workInProgress, + Component, + props, + renderExpirationTime ); + return child; } + + break; } } - 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 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( @@ -14016,13 +13932,13 @@ function mountIndeterminateComponent( var componentName = getComponentName(Component) || "Unknown"; if (!didWarnAboutBadClass[componentName]) { - warningWithoutStack$1( - false, + 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 ); + didWarnAboutBadClass[componentName] = true; } } @@ -14054,8 +13970,7 @@ function mountIndeterminateComponent( var _componentName = getComponentName(Component) || "Unknown"; if (!didWarnAboutModulePatternComponent[_componentName]) { - warningWithoutStack$1( - false, + 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. " + @@ -14065,6 +13980,7 @@ function mountIndeterminateComponent( _componentName, _componentName ); + didWarnAboutModulePatternComponent[_componentName] = true; } } // Proceed under the assumption that this is a class instance @@ -14086,6 +14002,7 @@ function mountIndeterminateComponent( workInProgress.memoizedState = value.state !== null && value.state !== undefined ? value.state : null; + initializeUpdateQueue(workInProgress); var getDerivedStateFromProps = Component.getDerivedStateFromProps; if (typeof getDerivedStateFromProps === "function") { @@ -14113,8 +14030,7 @@ function mountIndeterminateComponent( { if (disableLegacyContext && Component.contextTypes) { - warningWithoutStack$1( - false, + error( "%s uses the legacy contextTypes API which is no longer supported. " + "Use React.createContext() with React.useContext() instead.", getComponentName(Component) || "Unknown" @@ -14150,86 +14066,87 @@ function mountIndeterminateComponent( } function validateFunctionComponentInDev(workInProgress, Component) { - if (Component) { - !!Component.childContextTypes - ? warningWithoutStack$1( - false, + { + if (Component) { + if (Component.childContextTypes) { + error( "%s(...): childContextTypes cannot be defined on a function component.", Component.displayName || Component.name || "Component" - ) - : void 0; - } + ); + } + } - if (workInProgress.ref !== null) { - var info = ""; - var ownerName = getCurrentFiberOwnerNameInDevOrNull(); + if (workInProgress.ref !== null) { + var info = ""; + var ownerName = getCurrentFiberOwnerNameInDevOrNull(); - if (ownerName) { - info += "\n\nCheck the render method of `" + ownerName + "`."; - } + if (ownerName) { + info += "\n\nCheck the render method of `" + ownerName + "`."; + } - var warningKey = ownerName || workInProgress._debugID || ""; - var debugSource = workInProgress._debugSource; + var warningKey = ownerName || workInProgress._debugID || ""; + var debugSource = workInProgress._debugSource; - if (debugSource) { - warningKey = debugSource.fileName + ":" + debugSource.lineNumber; - } + if (debugSource) { + warningKey = debugSource.fileName + ":" + debugSource.lineNumber; + } - if (!didWarnAboutFunctionRefs[warningKey]) { - didWarnAboutFunctionRefs[warningKey] = true; - warning$1( - false, - "Function components cannot be given refs. " + - "Attempts to access this ref will fail. " + - "Did you mean to use React.forwardRef()?%s", - info - ); + 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 + ); + } } - } - if ( - warnAboutDefaultPropsOnFunctionComponents && - Component.defaultProps !== undefined - ) { - var componentName = getComponentName(Component) || "Unknown"; - - if (!didWarnAboutDefaultPropsOnFunctionComponent[componentName]) { - warningWithoutStack$1( - false, - "%s: Support for defaultProps will be removed from function components " + - "in a future major release. Use JavaScript default parameters instead.", - componentName - ); - didWarnAboutDefaultPropsOnFunctionComponent[componentName] = true; + if ( + warnAboutDefaultPropsOnFunctionComponents && + Component.defaultProps !== undefined + ) { + var componentName = getComponentName(Component) || "Unknown"; + + if (!didWarnAboutDefaultPropsOnFunctionComponent[componentName]) { + error( + "%s: Support for defaultProps will be removed from function components " + + "in a future major release. Use JavaScript default parameters instead.", + componentName + ); + + didWarnAboutDefaultPropsOnFunctionComponent[componentName] = true; + } } - } - if (typeof Component.getDerivedStateFromProps === "function") { - var _componentName2 = getComponentName(Component) || "Unknown"; + if (typeof Component.getDerivedStateFromProps === "function") { + var _componentName2 = getComponentName(Component) || "Unknown"; - if (!didWarnAboutGetDerivedStateOnFunctionComponent[_componentName2]) { - warningWithoutStack$1( - false, - "%s: Function components do not support getDerivedStateFromProps.", - _componentName2 - ); - didWarnAboutGetDerivedStateOnFunctionComponent[_componentName2] = true; + if (!didWarnAboutGetDerivedStateOnFunctionComponent[_componentName2]) { + error( + "%s: Function components do not support getDerivedStateFromProps.", + _componentName2 + ); + + didWarnAboutGetDerivedStateOnFunctionComponent[_componentName2] = true; + } } - } - if ( - typeof Component.contextType === "object" && - Component.contextType !== null - ) { - var _componentName3 = getComponentName(Component) || "Unknown"; + if ( + typeof Component.contextType === "object" && + Component.contextType !== null + ) { + var _componentName3 = getComponentName(Component) || "Unknown"; - if (!didWarnAboutContextTypeOnFunctionComponent[_componentName3]) { - warningWithoutStack$1( - false, - "%s: Function components do not support contextType.", - _componentName3 - ); - didWarnAboutContextTypeOnFunctionComponent[_componentName3] = true; + if (!didWarnAboutContextTypeOnFunctionComponent[_componentName3]) { + error( + "%s: Function components do not support contextType.", + _componentName3 + ); + + didWarnAboutContextTypeOnFunctionComponent[_componentName3] = true; + } } } } @@ -14301,8 +14218,8 @@ function updateSuspenseComponent( if ("maxDuration" in nextProps) { if (!didWarnAboutMaxDuration) { didWarnAboutMaxDuration = true; - warning$1( - false, + + error( "maxDuration has been removed from React. " + "Remove the maxDuration prop." ); @@ -14674,7 +14591,7 @@ function updateSuspenseComponent( workInProgress.child = _primaryChildFragment3; return _fallbackChildFragment3; } else { - // Still haven't timed out. Continue rendering the children, like we + // Still haven't timed out. Continue rendering the children, like we // normally do. workInProgress.memoizedState = null; var _nextPrimaryChildren2 = nextProps.children; @@ -14720,8 +14637,7 @@ function mountDehydratedSuspenseComponent( // Instead, we'll leave the content in place and try to hydrate it later. if ((workInProgress.mode & BlockingMode) === NoMode) { { - warning$1( - false, + error( "Cannot hydrate Suspense in legacy mode. Switch from " + "ReactDOM.hydrate(element, container) to " + "ReactDOM.createBlockingRoot(container, { hydrate: true })" + @@ -14981,40 +14897,39 @@ function validateRevealOrder(revealOrder) { case "together": case "forwards": case "backwards": { - warning$1( - false, + error( '"%s" is not a valid value for revealOrder on . ' + 'Use lowercase "%s" instead.', revealOrder, revealOrder.toLowerCase() ); + break; } case "forward": case "backward": { - warning$1( - false, + 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: - warning$1( - false, + error( '"%s" is not a supported revealOrder on . ' + 'Did you mean "together", "forwards" or "backwards"?', revealOrder ); + break; } } else { - warning$1( - false, + error( "%s is not a supported value for revealOrder on . " + 'Did you mean "together", "forwards" or "backwards"?', revealOrder @@ -15029,16 +14944,16 @@ function validateTailOptions(tailMode, revealOrder) { if (tailMode !== undefined && !didWarnAboutTailOptions[tailMode]) { if (tailMode !== "collapsed" && tailMode !== "hidden") { didWarnAboutTailOptions[tailMode] = true; - warning$1( - false, + + 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; - warning$1( - false, + + error( ' is only valid if revealOrder is ' + '"forwards" or "backwards". ' + 'Did you mean to specify revealOrder="forwards"?', @@ -15056,8 +14971,8 @@ function validateSuspenseListNestedChild(childSlot, index) { if (isArray || isIterable) { var type = isArray ? "array" : "iterable"; - warning$1( - false, + + error( "A nested %s was passed to row #%s in . Wrap it in " + "an additional SuspenseList to configure its revealOrder: " + " ... " + @@ -15067,6 +14982,7 @@ function validateSuspenseListNestedChild(childSlot, index) { index, type ); + return false; } } @@ -15107,8 +15023,7 @@ function validateSuspenseListChildren(children, revealOrder) { } } } else { - warning$1( - false, + 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?", @@ -15134,6 +15049,7 @@ function initSuspenseListRenderState( workInProgress.memoizedState = { isBackwards: isBackwards, rendering: null, + renderingStartTime: 0, last: lastContentRow, tail: tail, tailExpiration: 0, @@ -15144,6 +15060,7 @@ function initSuspenseListRenderState( // 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.tailExpiration = 0; @@ -15416,8 +15333,8 @@ function updateContextConsumer( if (context !== context.Consumer) { if (!hasWarnedAboutUsingContextAsConsumer) { hasWarnedAboutUsingContextAsConsumer = true; - warning$1( - false, + + error( "Rendering directly is not supported and will be removed in " + "a future major release. Did you mean to render instead?" ); @@ -15432,15 +15349,14 @@ function updateContextConsumer( var render = newProps.children; { - !(typeof render === "function") - ? warningWithoutStack$1( - false, - "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." - ) - : void 0; + 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." + ); + } } prepareToReadContext(workInProgress, renderExpirationTime); @@ -16048,6 +15964,22 @@ function beginWork$1(current$$1, workInProgress, renderExpirationTime) { break; } + + case Chunk: { + if (enableChunksAPI) { + var chunk = workInProgress.type; + var props = workInProgress.pendingProps; + return updateChunk( + current$$1, + workInProgress, + chunk, + props, + renderExpirationTime + ); + } + + break; + } } { @@ -16732,6 +16664,8 @@ if (supportsMutation) { // This lets the parents know that at least one of their children has changed. markUpdate(workInProgress); + } else { + workInProgress.stateNode = current.stateNode; } }; } else { @@ -16830,14 +16764,16 @@ function completeWork(current, workInProgress, renderExpirationTime) { switch (workInProgress.tag) { case IndeterminateComponent: - break; - case LazyComponent: - break; - case SimpleMemoComponent: case FunctionComponent: - break; + case ForwardRef: + case Fragment: + case Mode: + case Profiler: + case ContextConsumer: + case MemoComponent: + return null; case ClassComponent: { var Component = workInProgress.type; @@ -16846,7 +16782,7 @@ function completeWork(current, workInProgress, renderExpirationTime) { popContext(workInProgress); } - break; + return null; } case HostRoot: { @@ -16872,7 +16808,7 @@ function completeWork(current, workInProgress, renderExpirationTime) { } updateHostContainer(workInProgress); - break; + return null; } case HostComponent: { @@ -16889,9 +16825,9 @@ function completeWork(current, workInProgress, renderExpirationTime) { rootContainerInstance ); - if (enableFlareAPI) { - var prevListeners = current.memoizedProps.listeners; - var nextListeners = newProps.listeners; + if (enableDeprecatedFlareAPI) { + var prevListeners = current.memoizedProps.DEPRECATED_flareListeners; + var nextListeners = newProps.DEPRECATED_flareListeners; if (prevListeners !== nextListeners) { markUpdate(workInProgress); @@ -16909,12 +16845,12 @@ function completeWork(current, workInProgress, renderExpirationTime) { ); } // This can happen when we abort work. - break; + return null; } 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 we want to add then top->down or + // or completeWork depending on whether we want to add them top->down or // bottom->up. Top->down is faster in IE11. var _wasHydrated = popHydrationState(workInProgress); @@ -16929,16 +16865,16 @@ function completeWork(current, workInProgress, renderExpirationTime) { currentHostContext ) ) { - // If changes to the hydrated node needs to be applied at the + // If changes to the hydrated node need to be applied at the // commit-phase we mark this as such. markUpdate(workInProgress); } - if (enableFlareAPI) { - var listeners = newProps.listeners; + if (enableDeprecatedFlareAPI) { + var listeners = newProps.DEPRECATED_flareListeners; if (listeners != null) { - updateEventListeners( + updateDeprecatedEventListeners( listeners, workInProgress, rootContainerInstance @@ -16957,11 +16893,11 @@ function completeWork(current, workInProgress, renderExpirationTime) { workInProgress.stateNode = instance; - if (enableFlareAPI) { - var _listeners = newProps.listeners; + if (enableDeprecatedFlareAPI) { + var _listeners = newProps.DEPRECATED_flareListeners; if (_listeners != null) { - updateEventListeners( + updateDeprecatedEventListeners( _listeners, workInProgress, rootContainerInstance @@ -16990,7 +16926,7 @@ function completeWork(current, workInProgress, renderExpirationTime) { } } - break; + return null; } case HostText: { @@ -17030,12 +16966,9 @@ function completeWork(current, workInProgress, renderExpirationTime) { } } - break; + return null; } - case ForwardRef: - break; - case SuspenseComponent: { popSuspenseContext(workInProgress); var nextState = workInProgress.memoizedState; @@ -17061,15 +16994,14 @@ function completeWork(current, workInProgress, renderExpirationTime) { } else { // We should never have been in a hydration state if we didn't have a current. // However, in some of those paths, we might have reentered a hydration state - // and then we might be inside a hydration state. In that case, we'll need to - // exit out of it. + // and then we might be inside a hydration state. In that case, we'll need to exit out of it. resetHydrationState(); if ((workInProgress.effectTag & DidCapture) === NoEffect) { // This boundary did not suspend so it's now hydrated and unsuspended. workInProgress.memoizedState = null; } // If nothing suspended, we need to schedule an effect to mark this boundary - // as having hydrated so events know that they're free be invoked. + // as having hydrated so events know that they're free to be invoked. // It's also a signal to replay events and the suspense callback. // If something suspended, schedule an effect to attach retry listeners. // So we might as well always mark this. @@ -17162,7 +17094,7 @@ function completeWork(current, workInProgress, renderExpirationTime) { // 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 proimse. This flag is also used to hide the + // retry listener to the promise. This flag is also used to hide the // primary children. workInProgress.effectTag |= Update; } @@ -17172,9 +17104,9 @@ function completeWork(current, workInProgress, renderExpirationTime) { // 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 proimse. This flag is also used to hide the + // 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 the + // *unhide* children that were previously hidden, so check if this // is currently timed out, too. workInProgress.effectTag |= Update; } @@ -17189,33 +17121,18 @@ function completeWork(current, workInProgress, renderExpirationTime) { workInProgress.effectTag |= Update; } - break; + return null; } - case Fragment: - break; - - case Mode: - break; - - case Profiler: - break; - case HostPortal: popHostContainer(workInProgress); updateHostContainer(workInProgress); - break; + return null; case ContextProvider: // Pop provider fiber popProvider(workInProgress); - break; - - case ContextConsumer: - break; - - case MemoComponent: - break; + return null; case IncompleteClassComponent: { // Same as class component case. I put it down here so that the tags are @@ -17226,7 +17143,7 @@ function completeWork(current, workInProgress, renderExpirationTime) { popContext(workInProgress); } - break; + return null; } case SuspenseListComponent: { @@ -17234,9 +17151,9 @@ function completeWork(current, workInProgress, renderExpirationTime) { var renderState = workInProgress.memoizedState; if (renderState === null) { - // We're running in the default, "independent" mode. We don't do anything - // in this mode. - break; + // We're running in the default, "independent" mode. + // We don't do anything in this mode. + return null; } var didSuspendAlready = @@ -17352,7 +17269,10 @@ function completeWork(current, workInProgress, renderExpirationTime) { return null; } } else if ( - now() > renderState.tailExpiration && + // The time it took to render last row is greater than time until + // the expiration. + now() * 2 - renderState.renderingStartTime > + renderState.tailExpiration && renderExpirationTime > Never ) { // We have now passed our CPU deadline and we'll just give up further @@ -17402,13 +17322,19 @@ function completeWork(current, workInProgress, renderExpirationTime) { // Heuristic for how long we're willing to spend rendering rows // until we just give up and show what we have so far. var TAIL_EXPIRATION_TIMEOUT_MS = 500; - renderState.tailExpiration = now() + TAIL_EXPIRATION_TIMEOUT_MS; + renderState.tailExpiration = now() + TAIL_EXPIRATION_TIMEOUT_MS; // TODO: This is meant to mimic the train model or JND but this + // is a per component value. It should really be since the start + // of the total render or last commit. Consider using something like + // globalMostRecentFallbackTime. That doesn't account for being + // suspended for part of the time or when it's a new render. + // It should probably use a global start time value instead. } // Pop a row. var next = renderState.tail; renderState.rendering = next; renderState.tail = next.sibling; renderState.lastEffect = workInProgress.lastEffect; + 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. @@ -17429,7 +17355,7 @@ function completeWork(current, workInProgress, renderExpirationTime) { return next; } - break; + return null; } case FundamentalComponent: { @@ -17484,6 +17410,8 @@ function completeWork(current, workInProgress, renderExpirationTime) { markUpdate(workInProgress); } } + + return null; } break; @@ -17500,13 +17428,13 @@ function completeWork(current, workInProgress, renderExpirationTime) { workInProgress.stateNode = scopeInstance; scopeInstance.methods = createScopeMethods(_type3, scopeInstance); - if (enableFlareAPI) { - var _listeners2 = newProps.listeners; + if (enableDeprecatedFlareAPI) { + var _listeners2 = newProps.DEPRECATED_flareListeners; if (_listeners2 != null) { var _rootContainerInstance2 = getRootHostContainer(); - updateEventListeners( + updateDeprecatedEventListeners( _listeners2, workInProgress, _rootContainerInstance2 @@ -17519,9 +17447,10 @@ function completeWork(current, workInProgress, renderExpirationTime) { markUpdate(workInProgress); } } else { - if (enableFlareAPI) { - var _prevListeners = current.memoizedProps.listeners; - var _nextListeners = newProps.listeners; + if (enableDeprecatedFlareAPI) { + var _prevListeners = + current.memoizedProps.DEPRECATED_flareListeners; + var _nextListeners = newProps.DEPRECATED_flareListeners; if ( _prevListeners !== _nextListeners || @@ -17539,21 +17468,28 @@ function completeWork(current, workInProgress, renderExpirationTime) { markRef$1(workInProgress); } } + + return null; } break; } - default: { - throw Error( - "Unknown unit of work tag (" + - workInProgress.tag + - "). This error is likely caused by a bug in React. Please file an issue." - ); - } + case Chunk: + if (enableChunksAPI) { + return null; + } + + break; } - 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." + ); + } } function unwindWork(workInProgress, renderExpirationTime) { @@ -17746,7 +17682,8 @@ function logCapturedError(capturedError) { // However, the browser would have silenced the original error // so we'll print it first, and then print the stack addendum. - console.error(error); // For a more detailed description of this block, see: + console["error"](error); // Don't transform to our wrapper + // For a more detailed description of this block, see: // https://github.com/facebook/react/pull/13384 } @@ -17783,7 +17720,7 @@ function logCapturedError(capturedError) { // has already printed it. Even if the application swallows the error, it is still // displayed by the browser thanks to the DEV-only fake event trick in ReactErrorUtils. - console.error(combinedMessage); + console["error"](combinedMessage); // Don't transform to our wrapper } } @@ -17881,8 +17818,8 @@ function safelyCallDestroy(current$$1, destroy) { invokeGuardedCallback(null, destroy, null); if (hasCaughtError()) { - var error = clearCaughtError(); - captureCommitPhaseError(current$$1, error); + var error$$1 = clearCaughtError(); + captureCommitPhaseError(current$$1, error$$1); } } } @@ -17891,7 +17828,8 @@ function commitBeforeMutationLifeCycles(current$$1, finishedWork) { switch (finishedWork.tag) { case FunctionComponent: case ForwardRef: - case SimpleMemoComponent: { + case SimpleMemoComponent: + case Chunk: { commitHookEffectList(UnmountSnapshot, NoEffect$1, finishedWork); return; } @@ -17911,28 +17849,27 @@ function commitBeforeMutationLifeCycles(current$$1, finishedWork) { finishedWork.type === finishedWork.elementType && !didWarnAboutReassigningProps ) { - !(instance.props === finishedWork.memoizedProps) - ? warning$1( - false, - "Expected %s props to match memoized props before " + - "getSnapshotBeforeUpdate. " + - "This might either be because of a bug in React, or because " + - "a component reassigns its own `this.props`. " + - "Please file an issue.", - getComponentName(finishedWork.type) || "instance" - ) - : void 0; - !(instance.state === finishedWork.memoizedState) - ? warning$1( - false, - "Expected %s state to match memoized state before " + - "getSnapshotBeforeUpdate. " + - "This might either be because of a bug in React, or because " + - "a component reassigns its own `this.props`. " + - "Please file an issue.", - getComponentName(finishedWork.type) || "instance" - ) - : void 0; + if (instance.props !== finishedWork.memoizedProps) { + error( + "Expected %s props to match memoized props before " + + "getSnapshotBeforeUpdate. " + + "This might either be because of a bug in React, or because " + + "a component reassigns its own `this.props`. " + + "Please file an issue.", + getComponentName(finishedWork.type) || "instance" + ); + } + + if (instance.state !== finishedWork.memoizedState) { + error( + "Expected %s state to match memoized state before " + + "getSnapshotBeforeUpdate. " + + "This might either be because of a bug in React, or because " + + "a component reassigns its own `this.props`. " + + "Please file an issue.", + getComponentName(finishedWork.type) || "instance" + ); + } } } @@ -17948,8 +17885,8 @@ function commitBeforeMutationLifeCycles(current$$1, finishedWork) { if (snapshot === undefined && !didWarnSet.has(finishedWork.type)) { didWarnSet.add(finishedWork.type); - warningWithoutStack$1( - false, + + error( "%s.getSnapshotBeforeUpdate(): A snapshot value (or null) " + "must be returned. You have returned undefined.", getComponentName(finishedWork.type) @@ -17972,14 +17909,12 @@ function commitBeforeMutationLifeCycles(current$$1, finishedWork) { case IncompleteClassComponent: // Nothing to do for these component types return; + } - 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 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." + ); } } @@ -18035,8 +17970,7 @@ function commitHookEffectList(unmountTag, mountTag, finishedWork) { addendum = " You returned: " + _destroy; } - warningWithoutStack$1( - false, + error( "An effect function must not return anything besides a function, " + "which is used for clean-up.%s%s", addendum, @@ -18056,7 +17990,8 @@ function commitPassiveHookEffects(finishedWork) { switch (finishedWork.tag) { case FunctionComponent: case ForwardRef: - case SimpleMemoComponent: { + case SimpleMemoComponent: + case Chunk: { commitHookEffectList(UnmountPassive, NoEffect$1, finishedWork); commitHookEffectList(NoEffect$1, MountPassive, finishedWork); break; @@ -18077,9 +18012,10 @@ function commitLifeCycles( switch (finishedWork.tag) { case FunctionComponent: case ForwardRef: - case SimpleMemoComponent: { + case SimpleMemoComponent: + case Chunk: { commitHookEffectList(UnmountLayout, MountLayout, finishedWork); - break; + return; } case ClassComponent: { @@ -18096,28 +18032,27 @@ function commitLifeCycles( finishedWork.type === finishedWork.elementType && !didWarnAboutReassigningProps ) { - !(instance.props === finishedWork.memoizedProps) - ? warning$1( - false, - "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.", - getComponentName(finishedWork.type) || "instance" - ) - : void 0; - !(instance.state === finishedWork.memoizedState) - ? warning$1( - false, - "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.props`. " + - "Please file an issue.", - getComponentName(finishedWork.type) || "instance" - ) - : void 0; + 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.", + getComponentName(finishedWork.type) || "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.props`. " + + "Please file an issue.", + getComponentName(finishedWork.type) || "instance" + ); + } } } @@ -18141,28 +18076,27 @@ function commitLifeCycles( finishedWork.type === finishedWork.elementType && !didWarnAboutReassigningProps ) { - !(instance.props === finishedWork.memoizedProps) - ? warning$1( - false, - "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.", - getComponentName(finishedWork.type) || "instance" - ) - : void 0; - !(instance.state === finishedWork.memoizedState) - ? warning$1( - false, - "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.props`. " + - "Please file an issue.", - getComponentName(finishedWork.type) || "instance" - ) - : void 0; + 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.", + getComponentName(finishedWork.type) || "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.props`. " + + "Please file an issue.", + getComponentName(finishedWork.type) || "instance" + ); + } } } @@ -18183,28 +18117,27 @@ function commitLifeCycles( finishedWork.type === finishedWork.elementType && !didWarnAboutReassigningProps ) { - !(instance.props === finishedWork.memoizedProps) - ? warning$1( - false, - "Expected %s props to match memoized props before " + - "processing the update queue. " + - "This might either be because of a bug in React, or because " + - "a component reassigns its own `this.props`. " + - "Please file an issue.", - getComponentName(finishedWork.type) || "instance" - ) - : void 0; - !(instance.state === finishedWork.memoizedState) - ? warning$1( - false, - "Expected %s state to match memoized state before " + - "processing the update queue. " + - "This might either be because of a bug in React, or because " + - "a component reassigns its own `this.props`. " + - "Please file an issue.", - getComponentName(finishedWork.type) || "instance" - ) - : void 0; + if (instance.props !== finishedWork.memoizedProps) { + error( + "Expected %s props to match memoized props before " + + "processing the update queue. " + + "This might either be because of a bug in React, or because " + + "a component reassigns its own `this.props`. " + + "Please file an issue.", + getComponentName(finishedWork.type) || "instance" + ); + } + + if (instance.state !== finishedWork.memoizedState) { + error( + "Expected %s state to match memoized state before " + + "processing the update queue. " + + "This might either be because of a bug in React, or because " + + "a component reassigns its own `this.props`. " + + "Please file an issue.", + getComponentName(finishedWork.type) || "instance" + ); + } } } // We could update instance props and state here, // but instead we rely on them being set during last render. @@ -18315,14 +18248,12 @@ function commitLifeCycles( case FundamentalComponent: case ScopeComponent: return; + } - 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 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." + ); } } @@ -18409,8 +18340,7 @@ function commitAttachRef(finishedWork) { } else { { if (!ref.hasOwnProperty("current")) { - warningWithoutStack$1( - false, + error( "Unexpected ref object provided for %s. " + "Use either a ref-setter function or React.createRef().%s", getComponentName(finishedWork.type), @@ -18445,7 +18375,8 @@ function commitUnmount(finishedRoot, current$$1, renderPriorityLevel) { case FunctionComponent: case ForwardRef: case MemoComponent: - case SimpleMemoComponent: { + case SimpleMemoComponent: + case Chunk: { var updateQueue = current$$1.updateQueue; if (updateQueue !== null) { @@ -18485,7 +18416,7 @@ function commitUnmount(finishedRoot, current$$1, renderPriorityLevel) { } } - break; + return; } case ClassComponent: { @@ -18500,27 +18431,9 @@ function commitUnmount(finishedRoot, current$$1, renderPriorityLevel) { } case HostComponent: { - if (enableFlareAPI) { - var dependencies = current$$1.dependencies; - - if (dependencies !== null) { - var respondersMap = dependencies.responders; - - if (respondersMap !== null) { - var responderInstances = Array.from(respondersMap.values()); - - for ( - var i = 0, length = responderInstances.length; - i < length; - i++ - ) { - var responderInstance = responderInstances[i]; - unmountResponderInstance(responderInstance); - } - - dependencies.responders = null; - } - } + if (enableDeprecatedFlareAPI) { + unmountDeprecatedResponderListeners(current$$1); + beforeRemoveInstance(current$$1.stateNode); } safelyDetachRef(current$$1); @@ -18570,9 +18483,15 @@ function commitUnmount(finishedRoot, current$$1, renderPriorityLevel) { } case ScopeComponent: { + if (enableDeprecatedFlareAPI) { + unmountDeprecatedResponderListeners(current$$1); + } + if (enableScopeAPI) { safelyDetachRef(current$$1); } + + return; } } } @@ -18633,6 +18552,7 @@ function detachFiber(current$$1) { current$$1.lastEffect = null; current$$1.pendingProps = null; current$$1.memoizedProps = null; + current$$1.stateNode = null; if (alternate !== null) { detachFiber(alternate); @@ -18671,14 +18591,12 @@ function commitContainer(finishedWork) { replaceContainerChildren(containerInfo, pendingChildren); return; } + } - 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 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." + ); } } @@ -19012,7 +18930,8 @@ function commitWork(current$$1, finishedWork) { case FunctionComponent: case ForwardRef: case MemoComponent: - case SimpleMemoComponent: { + case SimpleMemoComponent: + case Chunk: { // Note: We currently never use MountMutation, but useLayout uses // UnmountMutation. commitHookEffectList(UnmountMutation, MountMutation, finishedWork); @@ -19057,7 +18976,8 @@ function commitWork(current$$1, finishedWork) { case FunctionComponent: case ForwardRef: case MemoComponent: - case SimpleMemoComponent: { + case SimpleMemoComponent: + case Chunk: { // Note: We currently never use MountMutation, but useLayout uses // UnmountMutation. commitHookEffectList(UnmountMutation, MountMutation, finishedWork); @@ -19095,12 +19015,12 @@ function commitWork(current$$1, finishedWork) { ); } - if (enableFlareAPI) { - var prevListeners = oldProps.listeners; - var nextListeners = newProps.listeners; + if (enableDeprecatedFlareAPI) { + var prevListeners = oldProps.DEPRECATED_flareListeners; + var nextListeners = newProps.DEPRECATED_flareListeners; if (prevListeners !== nextListeners) { - updateEventListeners(nextListeners, finishedWork, null); + updateDeprecatedEventListeners(nextListeners, finishedWork, null); } } } @@ -19162,9 +19082,10 @@ function commitWork(current$$1, finishedWork) { if (enableFundamentalAPI) { var fundamentalInstance = finishedWork.stateNode; updateFundamentalComponent(fundamentalInstance); + return; } - return; + break; } case ScopeComponent: { @@ -19172,31 +19093,31 @@ function commitWork(current$$1, finishedWork) { var scopeInstance = finishedWork.stateNode; scopeInstance.fiber = finishedWork; - if (enableFlareAPI) { + if (enableDeprecatedFlareAPI) { var _newProps = finishedWork.memoizedProps; var _oldProps = current$$1 !== null ? current$$1.memoizedProps : _newProps; - var _prevListeners = _oldProps.listeners; - var _nextListeners = _newProps.listeners; + var _prevListeners = _oldProps.DEPRECATED_flareListeners; + var _nextListeners = _newProps.DEPRECATED_flareListeners; - if (_prevListeners !== _nextListeners) { - updateEventListeners(_nextListeners, finishedWork, null); + if (_prevListeners !== _nextListeners || current$$1 === null) { + updateDeprecatedEventListeners(_nextListeners, finishedWork, null); } } + + return; } - return; + 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 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." + ); } } @@ -19228,7 +19149,7 @@ function commitSuspenseComponent(finishedWork) { } } else { if (suspenseCallback !== undefined) { - warning$1(false, "Unexpected type for suspenseCallback."); + error("Unexpected type for suspenseCallback."); } } } @@ -19321,10 +19242,10 @@ function createRootErrorUpdate(fiber, errorInfo, expirationTime) { update.payload = { element: null }; - var error = errorInfo.value; + var error$$1 = errorInfo.value; update.callback = function() { - onUncaughtError(error); + onUncaughtError(error$$1); logError(fiber, errorInfo); }; @@ -19337,11 +19258,11 @@ function createClassErrorUpdate(fiber, errorInfo, expirationTime) { var getDerivedStateFromError = fiber.type.getDerivedStateFromError; if (typeof getDerivedStateFromError === "function") { - var error = errorInfo.value; + var error$$1 = errorInfo.value; update.payload = function() { logError(fiber, errorInfo); - return getDerivedStateFromError(error); + return getDerivedStateFromError(error$$1); }; } @@ -19364,9 +19285,9 @@ function createClassErrorUpdate(fiber, errorInfo, expirationTime) { logError(fiber, errorInfo); } - var error = errorInfo.value; + var error$$1 = errorInfo.value; var stack = errorInfo.stack; - this.componentDidCatch(error, { + this.componentDidCatch(error$$1, { componentStack: stack !== null ? stack : "" }); @@ -19375,14 +19296,13 @@ function createClassErrorUpdate(fiber, errorInfo, expirationTime) { // If componentDidCatch is the only error boundary method defined, // then it needs to call setState to recover from errors. // If no state update is scheduled then the boundary will swallow the error. - !(fiber.expirationTime === Sync) - ? warningWithoutStack$1( - false, - "%s: Error boundaries should implement getDerivedStateFromError(). " + - "In that method, return a state update to display an error message or fallback UI.", - getComponentName(fiber.type) || "Unknown" - ) - : void 0; + if (fiber.expirationTime !== Sync) { + error( + "%s: Error boundaries should implement getDerivedStateFromError(). " + + "In that method, return a state update to display an error message or fallback UI.", + getComponentName(fiber.type) || "Unknown" + ); + } } } }; @@ -19447,6 +19367,20 @@ function throwException( ) { // This is a thenable. var thenable = value; + + if ((sourceFiber.mode & BlockingMode) === NoMode) { + // Reset the memoizedState to what it was before we attempted + // to render it. + var currentSource = sourceFiber.alternate; + + if (currentSource) { + sourceFiber.memoizedState = currentSource.memoizedState; + sourceFiber.expirationTime = currentSource.expirationTime; + } else { + sourceFiber.memoizedState = null; + } + } + checkForWrongSuspensePriorityInDEV(sourceFiber); var hasInvisibleParentBoundary = hasSuspenseContext( suspenseStackCursor.current, @@ -19972,9 +19906,21 @@ function getNextRootExpirationTimeToWorkOn(root) { var lastPingedTime = root.lastPingedTime; var nextKnownPendingLevel = root.nextKnownPendingLevel; - return lastPingedTime > nextKnownPendingLevel - ? lastPingedTime - : nextKnownPendingLevel; + var nextLevel = + lastPingedTime > nextKnownPendingLevel + ? lastPingedTime + : nextKnownPendingLevel; + + if ( + enableTrainModelFix && + nextLevel <= Idle && + firstPendingTime !== nextLevel + ) { + // Don't work on Idle/Never priority unless everything else is committed. + return NoWork; + } + + return nextLevel; } // Use this function to schedule a task for a root. There's only one task per // root; if a task was already scheduled, we'll check to make sure the // expiration time of the existing task is the same as the expiration time of @@ -20422,80 +20368,70 @@ function performSyncWorkOnRoot(root) { var lastExpiredTime = root.lastExpiredTime; var expirationTime = lastExpiredTime !== NoWork ? lastExpiredTime : Sync; - if (root.finishedExpirationTime === expirationTime) { - // There's already a pending commit at this expiration time. - // TODO: This is poorly factored. This case only exists for the - // batch.commit() API. - commitRoot(root); - } else { - if (!((executionContext & (RenderContext | CommitContext)) === NoContext)) { - throw Error("Should not already be working."); - } - - flushPassiveEffects(); // If the root or expiration time have changed, throw out the existing stack - // and prepare a fresh one. Otherwise we'll continue where we left off. - - if ( - root !== workInProgressRoot || - expirationTime !== renderExpirationTime - ) { - prepareFreshStack(root, expirationTime); - startWorkOnPendingInteractions(root, expirationTime); - } // If we have a work-in-progress fiber, it means there's still work to do - // in this root. + if (!((executionContext & (RenderContext | CommitContext)) === NoContext)) { + throw Error("Should not already be working."); + } - if (workInProgress !== null) { - var prevExecutionContext = executionContext; - executionContext |= RenderContext; - var prevDispatcher = pushDispatcher(root); - var prevInteractions = pushInteractions(root); - startWorkLoopTimer(workInProgress); + flushPassiveEffects(); // If the root or expiration time have changed, throw out the existing stack + // and prepare a fresh one. Otherwise we'll continue where we left off. - do { - try { - workLoopSync(); - break; - } catch (thrownValue) { - handleError(root, thrownValue); - } - } while (true); + if (root !== workInProgressRoot || expirationTime !== renderExpirationTime) { + prepareFreshStack(root, expirationTime); + startWorkOnPendingInteractions(root, expirationTime); + } // If we have a work-in-progress fiber, it means there's still work to do + // in this root. - resetContextDependencies(); - executionContext = prevExecutionContext; - popDispatcher(prevDispatcher); + if (workInProgress !== null) { + var prevExecutionContext = executionContext; + executionContext |= RenderContext; + var prevDispatcher = pushDispatcher(root); + var prevInteractions = pushInteractions(root); + startWorkLoopTimer(workInProgress); - if (enableSchedulerTracing) { - popInteractions(prevInteractions); + do { + try { + workLoopSync(); + break; + } catch (thrownValue) { + handleError(root, thrownValue); } + } while (true); - if (workInProgressRootExitStatus === RootFatalErrored) { - var fatalError = workInProgressRootFatalError; - stopInterruptedWorkLoopTimer(); - prepareFreshStack(root, expirationTime); - markRootSuspendedAtTime(root, expirationTime); - ensureRootIsScheduled(root); - throw fatalError; - } + resetContextDependencies(); + executionContext = prevExecutionContext; + popDispatcher(prevDispatcher); - if (workInProgress !== null) { - // This is a sync render, so we should have finished the whole tree. - { - throw Error( - "Cannot commit an incomplete root. This error is likely caused by a bug in React. Please file an issue." - ); - } - } else { - // We now have a consistent tree. Because this is a sync render, we - // will commit it even if something suspended. - stopFinishedWorkLoopTimer(); - root.finishedWork = root.current.alternate; - root.finishedExpirationTime = expirationTime; - finishSyncRender(root, workInProgressRootExitStatus, expirationTime); - } // Before exiting, make sure there's a callback scheduled for the next - // pending level. + if (enableSchedulerTracing) { + popInteractions(prevInteractions); + } + if (workInProgressRootExitStatus === RootFatalErrored) { + var fatalError = workInProgressRootFatalError; + stopInterruptedWorkLoopTimer(); + prepareFreshStack(root, expirationTime); + markRootSuspendedAtTime(root, expirationTime); ensureRootIsScheduled(root); + throw fatalError; } + + 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." + ); + } + } else { + // We now have a consistent tree. Because this is a sync render, we + // will commit it even if something suspended. + stopFinishedWorkLoopTimer(); + root.finishedWork = root.current.alternate; + root.finishedExpirationTime = expirationTime; + finishSyncRender(root, workInProgressRootExitStatus, expirationTime); + } // Before exiting, make sure there's a callback scheduled for the next + // pending level. + + ensureRootIsScheduled(root); } return null; @@ -20523,12 +20459,13 @@ function flushDiscreteUpdates() { (executionContext & (BatchedContext | RenderContext | CommitContext)) !== NoContext ) { - if (true && (executionContext & RenderContext) !== NoContext) { - warning$1( - false, - "unstable_flushDiscreteUpdates: Cannot flush updates when React is " + - "already rendering." - ); + { + if ((executionContext & RenderContext) !== NoContext) { + error( + "unstable_flushDiscreteUpdates: Cannot flush updates when React is " + + "already rendering." + ); + } } // We're already rendering, so we can't synchronously flush pending work. // This is probably a nested event dispatch triggered by a lifecycle/effect, // like `el.focus()`. Exit. @@ -21114,7 +21051,16 @@ function commitRoot(root) { } function commitRootImpl(root, renderPriorityLevel) { - flushPassiveEffects(); + do { + // `flushPassiveEffects` will call `flushSyncUpdateQueue` at the end, which + // means `flushPassiveEffects` will sometimes result in additional + // passive effects. So we need to keep flushing in a loop until there are + // no more pending effects. + // TODO: Might be better if `flushPassiveEffects` did not automatically + // flush synchronous work at the end, to avoid factoring hazards like this. + flushPassiveEffects(); + } while (rootWithPendingPassiveEffects !== null); + flushRenderPhaseStrictModeWarningsInDEV(); if (!((executionContext & (RenderContext | CommitContext)) === NoContext)) { @@ -21208,8 +21154,8 @@ function commitRootImpl(root, renderPriorityLevel) { throw Error("Should be working on an effect."); } - var error = clearCaughtError(); - captureCommitPhaseError(nextEffect, error); + var error$$1 = clearCaughtError(); + captureCommitPhaseError(nextEffect, error$$1); nextEffect = nextEffect.nextEffect; } } @@ -21581,8 +21527,8 @@ function flushPassiveEffectsImpl() { throw Error("Should be working on an effect."); } - var error = clearCaughtError(); - captureCommitPhaseError(effect, error); + var error$$1 = clearCaughtError(); + captureCommitPhaseError(effect, error$$1); } resetCurrentFiber(); @@ -21622,17 +21568,17 @@ function markLegacyErrorBoundaryAsFailed(instance) { } } -function prepareToThrowUncaughtError(error) { +function prepareToThrowUncaughtError(error$$1) { if (!hasUncaughtError) { hasUncaughtError = true; - firstUncaughtError = error; + firstUncaughtError = error$$1; } } var onUncaughtError = prepareToThrowUncaughtError; -function captureCommitPhaseErrorOnRoot(rootFiber, sourceFiber, error) { - var errorInfo = createCapturedValue(error, sourceFiber); +function captureCommitPhaseErrorOnRoot(rootFiber, sourceFiber, error$$1) { + var errorInfo = createCapturedValue(error$$1, sourceFiber); var update = createRootErrorUpdate(rootFiber, errorInfo, Sync); enqueueUpdate(rootFiber, update); var root = markUpdateTimeFromFiberToRoot(rootFiber, Sync); @@ -21643,11 +21589,11 @@ function captureCommitPhaseErrorOnRoot(rootFiber, sourceFiber, error) { } } -function captureCommitPhaseError(sourceFiber, error) { +function captureCommitPhaseError(sourceFiber, error$$1) { if (sourceFiber.tag === HostRoot) { // Error was thrown at the root. There is no parent, so the root // itself should capture it. - captureCommitPhaseErrorOnRoot(sourceFiber, sourceFiber, error); + captureCommitPhaseErrorOnRoot(sourceFiber, sourceFiber, error$$1); return; } @@ -21655,7 +21601,7 @@ function captureCommitPhaseError(sourceFiber, error) { while (fiber !== null) { if (fiber.tag === HostRoot) { - captureCommitPhaseErrorOnRoot(fiber, sourceFiber, error); + captureCommitPhaseErrorOnRoot(fiber, sourceFiber, error$$1); return; } else if (fiber.tag === ClassComponent) { var ctor = fiber.type; @@ -21666,7 +21612,7 @@ function captureCommitPhaseError(sourceFiber, error) { (typeof instance.componentDidCatch === "function" && !isAlreadyFailedLegacyErrorBoundary(instance)) ) { - var errorInfo = createCapturedValue(error, sourceFiber); + var errorInfo = createCapturedValue(error$$1, sourceFiber); var update = createClassErrorUpdate( fiber, errorInfo, // TODO: This is always sync @@ -21740,7 +21686,7 @@ function pingSuspendedRoot(root, thenable, suspendedTime) { root.lastPingedTime = suspendedTime; - if (root.finishedExpirationTime === suspendedTime) { + if (!enableTrainModelFix && root.finishedExpirationTime === suspendedTime) { // If there's a pending fallback waiting to commit, throw it away. root.finishedExpirationTime = NoWork; root.finishedWork = null; @@ -21894,8 +21840,8 @@ function checkForNestedUpdates() { { if (nestedPassiveUpdateCount > NESTED_PASSIVE_UPDATE_LIMIT) { nestedPassiveUpdateCount = 0; - warning$1( - false, + + error( "Maximum update depth exceeded. This can happen when a component " + "calls setState inside useEffect, but useEffect either doesn't " + "have a dependency array, or one of the dependencies changes on " + @@ -21950,7 +21896,8 @@ function warnAboutUpdateOnUnmountedFiberInDEV(fiber) { tag !== FunctionComponent && tag !== ForwardRef && tag !== MemoComponent && - tag !== SimpleMemoComponent + tag !== SimpleMemoComponent && + tag !== Chunk ) { // Only warn for user-defined components, not internal ones like Suspense. return; @@ -21969,8 +21916,7 @@ function warnAboutUpdateOnUnmountedFiberInDEV(fiber) { didWarnStateUpdateForUnmountedComponent = new Set([componentName]); } - warningWithoutStack$1( - false, + error( "Can't perform a React state update on an unmounted component. This " + "is a no-op, but it indicates a memory leak in your application. To " + "fix, cancel all subscriptions and asynchronous tasks in %s.%s", @@ -22061,10 +22007,10 @@ function warnAboutInvalidUpdatesOnClassComponentsInDEV(fiber) { return; } - warningWithoutStack$1( - false, + error( "setState(...): Cannot call setState() inside getChildContext()" ); + didWarnAboutUpdateInGetChildContext = true; break; @@ -22073,12 +22019,12 @@ function warnAboutInvalidUpdatesOnClassComponentsInDEV(fiber) { return; } - warningWithoutStack$1( - false, + error( "Cannot update during an existing state transition (such as " + "within `render`). Render methods should be a pure function of " + "props and state." ); + didWarnAboutUpdateInRender = true; break; } @@ -22096,8 +22042,7 @@ function warnIfNotScopedWithMatchingAct(fiber) { IsSomeRendererActing.current === true && IsThisRendererActing.current !== true ) { - warningWithoutStack$1( - false, + 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" + @@ -22123,8 +22068,7 @@ function warnIfNotCurrentlyActingEffectsInDEV(fiber) { IsSomeRendererActing.current === false && IsThisRendererActing.current === false ) { - warningWithoutStack$1( - 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" + @@ -22151,8 +22095,7 @@ function warnIfNotCurrentlyActingUpdatesInDEV(fiber) { IsSomeRendererActing.current === false && IsThisRendererActing.current === false ) { - warningWithoutStack$1( - false, + error( "An update to %s inside a test was not wrapped in act(...).\n\n" + "When testing, code that causes React state updates should be " + "wrapped into act(...):\n\n" + @@ -22186,8 +22129,8 @@ function warnIfUnmockedScheduler(fiber) { ) { if (fiber.mode & BlockingMode || fiber.mode & ConcurrentMode) { didWarnAboutUnmockedScheduler = true; - warningWithoutStack$1( - false, + + 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" + @@ -22196,8 +22139,8 @@ function warnIfUnmockedScheduler(fiber) { ); } else if (warnAboutUnmockedScheduler === true) { didWarnAboutUnmockedScheduler = true; - warningWithoutStack$1( - false, + + error( 'Starting from React v17, the "scheduler" module will need to be mocked ' + "to guarantee consistent behaviour across tests and browsers. " + "For example, with jest: \n" + @@ -22234,7 +22177,7 @@ function checkForWrongSuspensePriorityInDEV(sourceFiber) { var updateQueue = current$$1.updateQueue; if (updateQueue !== null) { - var update = updateQueue.firstUpdate; + var update = updateQueue.baseQueue; while (update !== null) { var priorityLevel = update.priority; @@ -22265,11 +22208,11 @@ function checkForWrongSuspensePriorityInDEV(sourceFiber) { case FunctionComponent: case ForwardRef: case SimpleMemoComponent: - if ( - workInProgressNode.memoizedState !== null && - workInProgressNode.memoizedState.baseUpdate !== null - ) { - var _update = workInProgressNode.memoizedState.baseUpdate; // Loop through the functional component's memoized state to see whether + case Chunk: { + var firstHook = current$$1.memoizedState; // TODO: This just checks the first Hook. Isn't it suppose to check all Hooks? + + if (firstHook !== null && firstHook.baseQueue !== null) { + var _update = firstHook.baseQueue; // Loop through the functional component's memoized state to see whether // the component has triggered any high pri updates while (_update !== null) { @@ -22292,9 +22235,7 @@ function checkForWrongSuspensePriorityInDEV(sourceFiber) { break; } - if ( - _update.next === workInProgressNode.memoizedState.baseUpdate - ) { + if (_update.next === firstHook.baseQueue) { break; } @@ -22303,6 +22244,7 @@ function checkForWrongSuspensePriorityInDEV(sourceFiber) { } break; + } default: break; @@ -22325,8 +22267,7 @@ function flushSuspensePriorityWarningInDEV() { componentsThatTriggeredHighPriSuspend = null; if (componentNames.length > 0) { - warningWithoutStack$1( - false, + error( "%s triggered a user-blocking update that suspended." + "\n\n" + "The fix is to split the update into multiple parts: a user-blocking " + @@ -22439,10 +22380,10 @@ function startWorkOnPendingInteractions(root, expirationTime) { try { subscriber.onWorkStarted(interactions, threadID); - } catch (error) { + } catch (error$$1) { // If the subscriber throws, rethrow it in a separate task scheduleCallback(ImmediatePriority, function() { - throw error; + throw error$$1; }); } } @@ -22464,10 +22405,10 @@ function finishPendingInteractions(root, committedExpirationTime) { var threadID = computeThreadID(root, committedExpirationTime); subscriber.onWorkStopped(root.memoizedInteractions, threadID); } - } catch (error) { + } catch (error$$1) { // If the subscriber throws, rethrow it in a separate task scheduleCallback(ImmediatePriority, function() { - throw error; + throw error$$1; }); } finally { // Clear completed interactions from the pending Map. @@ -22489,10 +22430,10 @@ function finishPendingInteractions(root, committedExpirationTime) { if (subscriber !== null && interaction.__count === 0) { try { subscriber.onInteractionScheduledWorkCompleted(interaction); - } catch (error) { + } catch (error$$1) { // If the subscriber throws, rethrow it in a separate task scheduleCallback(ImmediatePriority, function() { - throw error; + throw error$$1; }); } } @@ -22502,6 +22443,7 @@ function finishPendingInteractions(root, committedExpirationTime) { } } +var onScheduleFiberRoot = null; var onCommitFiberRoot = null; var onCommitFiberUnmount = null; var hasLoggedError = false; @@ -22523,8 +22465,7 @@ function injectInternals(internals) { if (!hook.supportsFiber) { { - warningWithoutStack$1( - false, + error( "The installed version of React DevTools is too old and will not work " + "with the current version of React. Please update React DevTools. " + "https://fb.me/react-devtools" @@ -22537,6 +22478,23 @@ function injectInternals(internals) { try { var rendererID = hook.inject(internals); // We have successfully injected, so now it is safe to set up hooks. + { + // Only used by Fast Refresh + if (typeof hook.onScheduleFiberRoot === "function") { + onScheduleFiberRoot = function(root, children) { + try { + hook.onScheduleFiberRoot(rendererID, root, children); + } catch (err) { + if (true && !hasLoggedError) { + hasLoggedError = true; + + error("React instrumentation encountered an error: %s", err); + } + } + }; + } + } + onCommitFiberRoot = function(root, expirationTime) { try { var didError = (root.current.effectTag & DidCapture) === DidCapture; @@ -22552,13 +22510,12 @@ function injectInternals(internals) { hook.onCommitFiberRoot(rendererID, root, undefined, didError); } } catch (err) { - if (true && !hasLoggedError) { - hasLoggedError = true; - warningWithoutStack$1( - false, - "React DevTools encountered an error: %s", - err - ); + { + if (!hasLoggedError) { + hasLoggedError = true; + + error("React instrumentation encountered an error: %s", err); + } } } }; @@ -22567,29 +22524,29 @@ function injectInternals(internals) { try { hook.onCommitFiberUnmount(rendererID, fiber); } catch (err) { - if (true && !hasLoggedError) { - hasLoggedError = true; - warningWithoutStack$1( - false, - "React DevTools encountered an error: %s", - err - ); + { + if (!hasLoggedError) { + hasLoggedError = true; + + error("React instrumentation encountered an error: %s", err); + } } } }; } catch (err) { // Catch all errors because it is unsafe to throw during initialization. { - warningWithoutStack$1( - false, - "React DevTools encountered an error: %s.", - err - ); + error("React instrumentation encountered an error: %s.", err); } } // DevTools exists return true; } +function onScheduleRoot(root, children) { + if (typeof onScheduleFiberRoot === "function") { + onScheduleFiberRoot(root, children); + } +} function onCommitRoot(root, expirationTime) { if (typeof onCommitFiberRoot === "function") { onCommitFiberRoot(root, expirationTime); @@ -22737,6 +22694,12 @@ function resolveLazyComponentTag(Component) { if ($$typeof === REACT_MEMO_TYPE) { return MemoComponent; } + + if (enableChunksAPI) { + if ($$typeof === REACT_CHUNK_TYPE) { + return Chunk; + } + } } return IndeterminateComponent; @@ -23017,6 +22980,10 @@ function createFiberFromTypeAndProps( resolvedType = null; break getTag; + case REACT_CHUNK_TYPE: + fiberTag = Chunk; + break getTag; + case REACT_FUNDAMENTAL_TYPE: if (enableFundamentalAPI) { return createFiberFromFundamental( @@ -23142,8 +23109,7 @@ function createFiberFromProfiler(pendingProps, mode, expirationTime, key) { typeof pendingProps.id !== "string" || typeof pendingProps.onRender !== "function" ) { - warningWithoutStack$1( - false, + error( 'Profiler must specify an "id" string and "onRender" function as props' ); } @@ -23305,6 +23271,7 @@ function createFiberRoot(containerInfo, tag, hydrate, hydrationCallbacks) { var uninitializedFiber = createHostRootFiber(tag); root.current = uninitializedFiber; uninitializedFiber.stateNode = root; + initializeUpdateQueue(uninitializedFiber); return root; } function isRootSuspendedAtTime(root, expirationTime) { @@ -23398,15 +23365,6 @@ function markRootExpiredAtTime(root, expirationTime) { } } -// This lets us hook into Fiber to debug what it's doing. -// See https://github.com/facebook/react/pull/8033. -// This is not part of the public API, not even for React DevTools. -// You may only inject a debugTool if you work on React Fiber itself. -var ReactFiberInstrumentation = { - debugTool: null -}; -var ReactFiberInstrumentation_1 = ReactFiberInstrumentation; - var didWarnAboutNestedUpdates; var didWarnAboutFindNodeInStrictMode; @@ -23493,8 +23451,7 @@ function findHostInstanceWithWarning(component, methodName) { didWarnAboutFindNodeInStrictMode[componentName] = true; if (fiber.mode & StrictMode) { - warningWithoutStack$1( - false, + error( "%s is deprecated in StrictMode. " + "%s was passed an instance of %s which is inside StrictMode. " + "Instead, add a ref directly to the element you want to reference. " + @@ -23506,8 +23463,7 @@ function findHostInstanceWithWarning(component, methodName) { getStackByFiberInDevAndProd(hostFiber) ); } else { - warningWithoutStack$1( - false, + error( "%s is deprecated in StrictMode. " + "%s was passed an instance of %s which renders StrictMode children. " + "Instead, add a ref directly to the element you want to reference. " + @@ -23532,6 +23488,10 @@ function createContainer(containerInfo, tag, hydrate, hydrationCallbacks) { return createFiberRoot(containerInfo, tag, hydrate, hydrationCallbacks); } function updateContainer(element, container, parentComponent, callback) { + { + onScheduleRoot(container, element); + } + var current$$1 = container.current; var currentTime = requestCurrentTimeForUpdate(); @@ -23549,19 +23509,6 @@ function updateContainer(element, container, parentComponent, callback) { current$$1, suspenseConfig ); - - { - if (ReactFiberInstrumentation_1.debugTool) { - if (current$$1.alternate === null) { - ReactFiberInstrumentation_1.debugTool.onMountContainer(container); - } else if (element === null) { - ReactFiberInstrumentation_1.debugTool.onUnmountContainer(container); - } else { - ReactFiberInstrumentation_1.debugTool.onUpdateContainer(container); - } - } - } - var context = getContextForSubtree(parentComponent); if (container.context === null) { @@ -23573,8 +23520,8 @@ function updateContainer(element, container, parentComponent, callback) { { if (phase === "render" && current !== null && !didWarnAboutNestedUpdates) { didWarnAboutNestedUpdates = true; - warningWithoutStack$1( - false, + + error( "Render methods should be a pure function of props and state; " + "triggering nested component updates from render is not allowed. " + "If necessary, trigger nested updates in componentDidUpdate.\n\n" + @@ -23593,14 +23540,16 @@ function updateContainer(element, container, parentComponent, callback) { callback = callback === undefined ? null : callback; if (callback !== null) { - !(typeof callback === "function") - ? warningWithoutStack$1( - false, + { + if (typeof callback !== "function") { + error( "render(...): Expected the last optional `callback` argument to be a " + "function. Instead received: %s.", callback - ) - : void 0; + ); + } + } + update.callback = callback; } @@ -23758,7 +23707,7 @@ function createPortal( // TODO: this is special because it gets imported during build. -var ReactVersion = "16.11.0"; +var ReactVersion = "16.12.0-19f6fe170"; var NativeMethodsMixin = function(findNodeHandle, findHostInstance) { /** @@ -23802,7 +23751,7 @@ var NativeMethodsMixin = function(findNodeHandle, findHostInstance) { try { maybeInstance = findHostInstance(this); - } catch (error) {} // If there is no host component beneath this we should fail silently. + } catch (error$$1) {} // If there is no host component beneath this we should fail silently. // This is not an error; it could mean a class component rendered null. if (maybeInstance == null) { @@ -23848,7 +23797,7 @@ var NativeMethodsMixin = function(findNodeHandle, findHostInstance) { try { maybeInstance = findHostInstance(this); - } catch (error) {} // If there is no host component beneath this we should fail silently. + } catch (error$$1) {} // If there is no host component beneath this we should fail silently. // This is not an error; it could mean a class component rendered null. if (maybeInstance == null) { @@ -23892,7 +23841,7 @@ var NativeMethodsMixin = function(findNodeHandle, findHostInstance) { try { maybeInstance = findHostInstance(this); - } catch (error) {} // If there is no host component beneath this we should fail silently. + } catch (error$$1) {} // If there is no host component beneath this we should fail silently. // This is not an error; it could mean a class component rendered null. if (maybeInstance == null) { @@ -23900,12 +23849,14 @@ var NativeMethodsMixin = function(findNodeHandle, findHostInstance) { } if (maybeInstance.canonical) { - warningWithoutStack$1( - false, - "Warning: measureLayout on components using NativeMethodsMixin " + - "or ReactNative.NativeComponent is not currently supported in Fabric. " + - "measureLayout must be called on a native ref. Consider using forwardRef." - ); + { + error( + "Warning: measureLayout on components using NativeMethodsMixin " + + "or ReactNative.NativeComponent is not currently supported in Fabric. " + + "measureLayout must be called on a native ref. Consider using forwardRef." + ); + } + return; } else { var relativeNode; @@ -23918,10 +23869,12 @@ var NativeMethodsMixin = function(findNodeHandle, findHostInstance) { } if (relativeNode == null) { - warningWithoutStack$1( - false, - "Warning: ref.measureLayout must be called with a node handle or a ref to a native component." - ); + { + error( + "Warning: ref.measureLayout must be called with a node handle or a ref to a native component." + ); + } + return; } @@ -23953,7 +23906,7 @@ var NativeMethodsMixin = function(findNodeHandle, findHostInstance) { try { maybeInstance = findHostInstance(this); - } catch (error) {} // If there is no host component beneath this we should fail silently. + } catch (error$$1) {} // If there is no host component beneath this we should fail silently. // This is not an error; it could mean a class component rendered null. if (maybeInstance == null) { @@ -23961,10 +23914,10 @@ var NativeMethodsMixin = function(findNodeHandle, findHostInstance) { } if (maybeInstance.canonical) { - warningWithoutStack$1( - false, - "Warning: setNativeProps is not currently supported in Fabric" - ); + { + error("Warning: setNativeProps is not currently supported in Fabric"); + } + return; } @@ -24130,7 +24083,7 @@ var ReactNativeComponent = function(findNodeHandle, findHostInstance) { try { maybeInstance = findHostInstance(this); - } catch (error) {} // If there is no host component beneath this we should fail silently. + } catch (error$$1) {} // If there is no host component beneath this we should fail silently. // This is not an error; it could mean a class component rendered null. if (maybeInstance == null) { @@ -24174,7 +24127,7 @@ var ReactNativeComponent = function(findNodeHandle, findHostInstance) { try { maybeInstance = findHostInstance(this); - } catch (error) {} // If there is no host component beneath this we should fail silently. + } catch (error$$1) {} // If there is no host component beneath this we should fail silently. // This is not an error; it could mean a class component rendered null. if (maybeInstance == null) { @@ -24215,7 +24168,7 @@ var ReactNativeComponent = function(findNodeHandle, findHostInstance) { try { maybeInstance = findHostInstance(this); - } catch (error) {} // If there is no host component beneath this we should fail silently. + } catch (error$$1) {} // If there is no host component beneath this we should fail silently. // This is not an error; it could mean a class component rendered null. if (maybeInstance == null) { @@ -24223,12 +24176,14 @@ var ReactNativeComponent = function(findNodeHandle, findHostInstance) { } if (maybeInstance.canonical) { - warningWithoutStack$1( - false, - "Warning: measureLayout on components using NativeMethodsMixin " + - "or ReactNative.NativeComponent is not currently supported in Fabric. " + - "measureLayout must be called on a native ref. Consider using forwardRef." - ); + { + error( + "Warning: measureLayout on components using NativeMethodsMixin " + + "or ReactNative.NativeComponent is not currently supported in Fabric. " + + "measureLayout must be called on a native ref. Consider using forwardRef." + ); + } + return; } else { var relativeNode; @@ -24241,10 +24196,12 @@ var ReactNativeComponent = function(findNodeHandle, findHostInstance) { } if (relativeNode == null) { - warningWithoutStack$1( - false, - "Warning: ref.measureLayout must be called with a node handle or a ref to a native component." - ); + { + error( + "Warning: ref.measureLayout must be called with a node handle or a ref to a native component." + ); + } + return; } @@ -24276,7 +24233,7 @@ var ReactNativeComponent = function(findNodeHandle, findHostInstance) { try { maybeInstance = findHostInstance(this); - } catch (error) {} // If there is no host component beneath this we should fail silently. + } catch (error$$1) {} // If there is no host component beneath this we should fail silently. // This is not an error; it could mean a class component rendered null. if (maybeInstance == null) { @@ -24284,10 +24241,12 @@ var ReactNativeComponent = function(findNodeHandle, findHostInstance) { } if (maybeInstance.canonical) { - warningWithoutStack$1( - false, - "Warning: setNativeProps is not currently supported in Fabric" - ); + { + error( + "Warning: setNativeProps is not currently supported in Fabric" + ); + } + return; } @@ -24432,17 +24391,17 @@ function findHostInstance_DEPRECATED(componentOrHandle) { var owner = ReactCurrentOwner.current; if (owner !== null && owner.stateNode !== null) { - !owner.stateNode._warnedAboutRefsInRender - ? warningWithoutStack$1( - false, - "%s is accessing findNodeHandle inside its render(). " + - "render() should be a pure function of props and state. It should " + - "never access something that requires stale data from the previous " + - "render, such as refs. Move this logic to componentDidMount and " + - "componentDidUpdate instead.", - getComponentName(owner.type) || "A component" - ) - : void 0; + if (!owner.stateNode._warnedAboutRefsInRender) { + error( + "%s is accessing findNodeHandle inside its render(). " + + "render() should be a pure function of props and state. It should " + + "never access something that requires stale data from the previous " + + "render, such as refs. Move this logic to componentDidMount and " + + "componentDidUpdate instead.", + getComponentName(owner.type) || "A component" + ); + } + owner.stateNode._warnedAboutRefsInRender = true; } } @@ -24485,17 +24444,17 @@ function findNodeHandle(componentOrHandle) { var owner = ReactCurrentOwner.current; if (owner !== null && owner.stateNode !== null) { - !owner.stateNode._warnedAboutRefsInRender - ? warningWithoutStack$1( - false, - "%s is accessing findNodeHandle inside its render(). " + - "render() should be a pure function of props and state. It should " + - "never access something that requires stale data from the previous " + - "render, such as refs. Move this logic to componentDidMount and " + - "componentDidUpdate instead.", - getComponentName(owner.type) || "A component" - ) - : void 0; + if (!owner.stateNode._warnedAboutRefsInRender) { + error( + "%s is accessing findNodeHandle inside its render(). " + + "render() should be a pure function of props and state. It should " + + "never access something that requires stale data from the previous " + + "render, such as refs. Move this logic to componentDidMount and " + + "componentDidUpdate instead.", + getComponentName(owner.type) || "A component" + ); + } + owner.stateNode._warnedAboutRefsInRender = true; } } @@ -24564,21 +24523,29 @@ var ReactNativeRenderer = { findNodeHandle: findNodeHandle, dispatchCommand: function(handle, command, args) { if (handle._nativeTag == null) { - !(handle._nativeTag != null) - ? warningWithoutStack$1( - false, - "dispatchCommand was called with a ref that isn't a " + - "native component. Use React.forwardRef to get access to the underlying native component" - ) - : void 0; + { + error( + "dispatchCommand was called with a ref that isn't a " + + "native component. Use React.forwardRef to get access to the underlying native component" + ); + } + return; } - ReactNativePrivateInterface.UIManager.dispatchViewManagerCommand( - handle._nativeTag, - command, - args - ); + if (handle._internalInstanceHandle) { + nativeFabricUIManager.dispatchCommand( + handle._internalInstanceHandle.stateNode.node, + command, + args + ); + } else { + ReactNativePrivateInterface.UIManager.dispatchViewManagerCommand( + handle._nativeTag, + command, + args + ); + } }, render: function(element, containerTag, callback) { var root = roots.get(containerTag); diff --git a/Libraries/Renderer/implementations/ReactNativeRenderer-prod.fb.js b/Libraries/Renderer/implementations/ReactNativeRenderer-prod.fb.js index c8107e4934204a..8f8de75dd00dee 100644 --- a/Libraries/Renderer/implementations/ReactNativeRenderer-prod.fb.js +++ b/Libraries/Renderer/implementations/ReactNativeRenderer-prod.fb.js @@ -502,53 +502,27 @@ function recordTouchStart(touch) { } function recordTouchMove(touch) { var touchRecord = touchBank[getTouchIdentifier(touch)]; - touchRecord - ? ((touchRecord.touchActive = !0), - (touchRecord.previousPageX = touchRecord.currentPageX), - (touchRecord.previousPageY = touchRecord.currentPageY), - (touchRecord.previousTimeStamp = touchRecord.currentTimeStamp), - (touchRecord.currentPageX = touch.pageX), - (touchRecord.currentPageY = touch.pageY), - (touchRecord.currentTimeStamp = timestampForTouch(touch)), - (touchHistory.mostRecentTimeStamp = timestampForTouch(touch))) - : console.warn( - "Cannot record touch move without a touch start.\nTouch Move: %s\n", - "Touch Bank: %s", - printTouch(touch), - printTouchBank() - ); + touchRecord && + ((touchRecord.touchActive = !0), + (touchRecord.previousPageX = touchRecord.currentPageX), + (touchRecord.previousPageY = touchRecord.currentPageY), + (touchRecord.previousTimeStamp = touchRecord.currentTimeStamp), + (touchRecord.currentPageX = touch.pageX), + (touchRecord.currentPageY = touch.pageY), + (touchRecord.currentTimeStamp = timestampForTouch(touch)), + (touchHistory.mostRecentTimeStamp = timestampForTouch(touch))); } function recordTouchEnd(touch) { var touchRecord = touchBank[getTouchIdentifier(touch)]; - touchRecord - ? ((touchRecord.touchActive = !1), - (touchRecord.previousPageX = touchRecord.currentPageX), - (touchRecord.previousPageY = touchRecord.currentPageY), - (touchRecord.previousTimeStamp = touchRecord.currentTimeStamp), - (touchRecord.currentPageX = touch.pageX), - (touchRecord.currentPageY = touch.pageY), - (touchRecord.currentTimeStamp = timestampForTouch(touch)), - (touchHistory.mostRecentTimeStamp = timestampForTouch(touch))) - : console.warn( - "Cannot record touch end without a touch start.\nTouch End: %s\n", - "Touch Bank: %s", - printTouch(touch), - printTouchBank() - ); -} -function printTouch(touch) { - return JSON.stringify({ - identifier: touch.identifier, - pageX: touch.pageX, - pageY: touch.pageY, - timestamp: timestampForTouch(touch) - }); -} -function printTouchBank() { - var printed = JSON.stringify(touchBank.slice(0, 20)); - 20 < touchBank.length && - (printed += " (original size: " + touchBank.length + ")"); - return printed; + touchRecord && + ((touchRecord.touchActive = !1), + (touchRecord.previousPageX = touchRecord.currentPageX), + (touchRecord.previousPageY = touchRecord.currentPageY), + (touchRecord.previousTimeStamp = touchRecord.currentTimeStamp), + (touchRecord.currentPageX = touch.pageX), + (touchRecord.currentPageY = touch.pageY), + (touchRecord.currentTimeStamp = timestampForTouch(touch)), + (touchHistory.mostRecentTimeStamp = timestampForTouch(touch))); } var ResponderTouchHistoryStore = { recordTouchTrack: function(topLevelType, nativeEvent) { @@ -681,13 +655,7 @@ var eventTypes = { "topTouchCancel" === topLevelType ) if (0 <= trackedTouchCount) --trackedTouchCount; - else - return ( - console.warn( - "Ended a touch event which was not counted in `trackedTouchCount`." - ), - null - ); + else return null; ResponderTouchHistoryStore.recordTouchTrack(topLevelType, nativeEvent); if ( targetInst && @@ -1159,7 +1127,8 @@ var hasSymbol = "function" === typeof Symbol && Symbol.for, ? Symbol.for("react.suspense_list") : 60120, REACT_MEMO_TYPE = hasSymbol ? Symbol.for("react.memo") : 60115, - REACT_LAZY_TYPE = hasSymbol ? Symbol.for("react.lazy") : 60116; + REACT_LAZY_TYPE = hasSymbol ? Symbol.for("react.lazy") : 60116, + REACT_CHUNK_TYPE = hasSymbol ? Symbol.for("react.chunk") : 60121; hasSymbol && Symbol.for("react.fundamental"); hasSymbol && Symbol.for("react.responder"); hasSymbol && Symbol.for("react.scope"); @@ -1224,6 +1193,8 @@ function getComponentName(type) { ); case REACT_MEMO_TYPE: return getComponentName(type.type); + case REACT_CHUNK_TYPE: + return getComponentName(type.render); case REACT_LAZY_TYPE: if ((type = 1 === type._status ? type._result : null)) return getComponentName(type); @@ -2017,237 +1988,195 @@ function readContext(context, observedBits) { return context._currentValue; } var hasForceUpdate = !1; -function createUpdateQueue(baseState) { - return { - baseState: baseState, - firstUpdate: null, - lastUpdate: null, - firstCapturedUpdate: null, - lastCapturedUpdate: null, - firstEffect: null, - lastEffect: null, - firstCapturedEffect: null, - lastCapturedEffect: null +function initializeUpdateQueue(fiber) { + fiber.updateQueue = { + baseState: fiber.memoizedState, + baseQueue: null, + shared: { pending: null }, + effects: null }; } -function cloneUpdateQueue(currentQueue) { - return { - baseState: currentQueue.baseState, - firstUpdate: currentQueue.firstUpdate, - lastUpdate: currentQueue.lastUpdate, - firstCapturedUpdate: null, - lastCapturedUpdate: null, - firstEffect: null, - lastEffect: null, - firstCapturedEffect: null, - lastCapturedEffect: null - }; +function cloneUpdateQueue(current, workInProgress) { + current = current.updateQueue; + workInProgress.updateQueue === current && + (workInProgress.updateQueue = { + baseState: current.baseState, + baseQueue: current.baseQueue, + shared: current.shared, + effects: current.effects + }); } function createUpdate(expirationTime, suspenseConfig) { - return { + expirationTime = { expirationTime: expirationTime, suspenseConfig: suspenseConfig, tag: 0, payload: null, callback: null, - next: null, - nextEffect: null + next: null }; -} -function appendUpdateToQueue(queue, update) { - null === queue.lastUpdate - ? (queue.firstUpdate = queue.lastUpdate = update) - : ((queue.lastUpdate.next = update), (queue.lastUpdate = update)); + return (expirationTime.next = expirationTime); } function enqueueUpdate(fiber, update) { - var alternate = fiber.alternate; - if (null === alternate) { - var queue1 = fiber.updateQueue; - var queue2 = null; - null === queue1 && - (queue1 = fiber.updateQueue = createUpdateQueue(fiber.memoizedState)); - } else - (queue1 = fiber.updateQueue), - (queue2 = alternate.updateQueue), - null === queue1 - ? null === queue2 - ? ((queue1 = fiber.updateQueue = createUpdateQueue( - fiber.memoizedState - )), - (queue2 = alternate.updateQueue = createUpdateQueue( - alternate.memoizedState - ))) - : (queue1 = fiber.updateQueue = cloneUpdateQueue(queue2)) - : null === queue2 && - (queue2 = alternate.updateQueue = cloneUpdateQueue(queue1)); - null === queue2 || queue1 === queue2 - ? appendUpdateToQueue(queue1, update) - : null === queue1.lastUpdate || null === queue2.lastUpdate - ? (appendUpdateToQueue(queue1, update), - appendUpdateToQueue(queue2, update)) - : (appendUpdateToQueue(queue1, update), (queue2.lastUpdate = update)); + fiber = fiber.updateQueue; + if (null !== fiber) { + fiber = fiber.shared; + var pending = fiber.pending; + null === pending + ? (update.next = update) + : ((update.next = pending.next), (pending.next = update)); + fiber.pending = update; + } } function enqueueCapturedUpdate(workInProgress, update) { - var workInProgressQueue = workInProgress.updateQueue; - workInProgressQueue = - null === workInProgressQueue - ? (workInProgress.updateQueue = createUpdateQueue( - workInProgress.memoizedState - )) - : ensureWorkInProgressQueueIsAClone(workInProgress, workInProgressQueue); - null === workInProgressQueue.lastCapturedUpdate - ? (workInProgressQueue.firstCapturedUpdate = workInProgressQueue.lastCapturedUpdate = update) - : ((workInProgressQueue.lastCapturedUpdate.next = update), - (workInProgressQueue.lastCapturedUpdate = update)); -} -function ensureWorkInProgressQueueIsAClone(workInProgress, queue) { var current = workInProgress.alternate; - null !== current && - queue === current.updateQueue && - (queue = workInProgress.updateQueue = cloneUpdateQueue(queue)); - return queue; -} -function getStateFromUpdate( - workInProgress, - queue, - update, - prevState, - nextProps, - instance -) { - switch (update.tag) { - case 1: - return ( - (workInProgress = update.payload), - "function" === typeof workInProgress - ? workInProgress.call(instance, prevState, nextProps) - : workInProgress - ); - case 3: - workInProgress.effectTag = (workInProgress.effectTag & -4097) | 64; - case 0: - workInProgress = update.payload; - nextProps = - "function" === typeof workInProgress - ? workInProgress.call(instance, prevState, nextProps) - : workInProgress; - if (null === nextProps || void 0 === nextProps) break; - return Object.assign({}, prevState, nextProps); - case 2: - hasForceUpdate = !0; - } - return prevState; + null !== current && cloneUpdateQueue(current, workInProgress); + workInProgress = workInProgress.updateQueue; + current = workInProgress.baseQueue; + null === current + ? ((workInProgress.baseQueue = update.next = update), + (update.next = update)) + : ((update.next = current.next), (current.next = update)); } function processUpdateQueue( - workInProgress, - queue, + workInProgress$jscomp$0, props, instance, renderExpirationTime ) { + var queue = workInProgress$jscomp$0.updateQueue; hasForceUpdate = !1; - queue = ensureWorkInProgressQueueIsAClone(workInProgress, queue); - for ( - var newBaseState = queue.baseState, - newFirstUpdate = null, - newExpirationTime = 0, - update = queue.firstUpdate, - resultState = newBaseState; - null !== update; - - ) { - var updateExpirationTime = update.expirationTime; - updateExpirationTime < renderExpirationTime - ? (null === newFirstUpdate && - ((newFirstUpdate = update), (newBaseState = resultState)), - newExpirationTime < updateExpirationTime && - (newExpirationTime = updateExpirationTime)) - : (markRenderEventTimeAndConfig( - updateExpirationTime, - update.suspenseConfig - ), - (resultState = getStateFromUpdate( - workInProgress, - queue, - update, - resultState, - props, - instance - )), - null !== update.callback && - ((workInProgress.effectTag |= 32), - (update.nextEffect = null), - null === queue.lastEffect - ? (queue.firstEffect = queue.lastEffect = update) - : ((queue.lastEffect.nextEffect = update), - (queue.lastEffect = update)))); - update = update.next; + var baseQueue = queue.baseQueue, + pendingQueue = queue.shared.pending; + if (null !== pendingQueue) { + if (null !== baseQueue) { + var baseFirst = baseQueue.next; + baseQueue.next = pendingQueue.next; + pendingQueue.next = baseFirst; + } + baseQueue = pendingQueue; + queue.shared.pending = null; + baseFirst = workInProgress$jscomp$0.alternate; + null !== baseFirst && + ((baseFirst = baseFirst.updateQueue), + null !== baseFirst && (baseFirst.baseQueue = pendingQueue)); } - updateExpirationTime = null; - for (update = queue.firstCapturedUpdate; null !== update; ) { - var _updateExpirationTime = update.expirationTime; - _updateExpirationTime < renderExpirationTime - ? (null === updateExpirationTime && - ((updateExpirationTime = update), - null === newFirstUpdate && (newBaseState = resultState)), - newExpirationTime < _updateExpirationTime && - (newExpirationTime = _updateExpirationTime)) - : ((resultState = getStateFromUpdate( - workInProgress, - queue, - update, - resultState, - props, - instance - )), - null !== update.callback && - ((workInProgress.effectTag |= 32), - (update.nextEffect = null), - null === queue.lastCapturedEffect - ? (queue.firstCapturedEffect = queue.lastCapturedEffect = update) - : ((queue.lastCapturedEffect.nextEffect = update), - (queue.lastCapturedEffect = update)))); - update = update.next; + if (null !== baseQueue) { + baseFirst = baseQueue.next; + var newState = queue.baseState, + newExpirationTime = 0, + newBaseState = null, + newBaseQueueFirst = null, + newBaseQueueLast = null; + if (null !== baseFirst) { + var update = baseFirst; + do { + pendingQueue = update.expirationTime; + if (pendingQueue < renderExpirationTime) { + var clone = { + expirationTime: update.expirationTime, + suspenseConfig: update.suspenseConfig, + tag: update.tag, + payload: update.payload, + callback: update.callback, + next: null + }; + null === newBaseQueueLast + ? ((newBaseQueueFirst = newBaseQueueLast = clone), + (newBaseState = newState)) + : (newBaseQueueLast = newBaseQueueLast.next = clone); + pendingQueue > newExpirationTime && + (newExpirationTime = pendingQueue); + } else { + null !== newBaseQueueLast && + (newBaseQueueLast = newBaseQueueLast.next = { + expirationTime: 1073741823, + suspenseConfig: update.suspenseConfig, + tag: update.tag, + payload: update.payload, + callback: update.callback, + next: null + }); + markRenderEventTimeAndConfig(pendingQueue, update.suspenseConfig); + a: { + var workInProgress = workInProgress$jscomp$0, + update$jscomp$0 = update; + pendingQueue = props; + clone = instance; + switch (update$jscomp$0.tag) { + case 1: + workInProgress = update$jscomp$0.payload; + if ("function" === typeof workInProgress) { + newState = workInProgress.call(clone, newState, pendingQueue); + break a; + } + newState = workInProgress; + break a; + case 3: + workInProgress.effectTag = + (workInProgress.effectTag & -4097) | 64; + case 0: + workInProgress = update$jscomp$0.payload; + pendingQueue = + "function" === typeof workInProgress + ? workInProgress.call(clone, newState, pendingQueue) + : workInProgress; + if (null === pendingQueue || void 0 === pendingQueue) break a; + newState = Object.assign({}, newState, pendingQueue); + break a; + case 2: + hasForceUpdate = !0; + } + } + null !== update.callback && + ((workInProgress$jscomp$0.effectTag |= 32), + (pendingQueue = queue.effects), + null === pendingQueue + ? (queue.effects = [update]) + : pendingQueue.push(update)); + } + update = update.next; + if (null === update || update === baseFirst) + if (((pendingQueue = queue.shared.pending), null === pendingQueue)) + break; + else + (update = baseQueue.next = pendingQueue.next), + (pendingQueue.next = baseFirst), + (queue.baseQueue = baseQueue = pendingQueue), + (queue.shared.pending = null); + } while (1); + } + null === newBaseQueueLast + ? (newBaseState = newState) + : (newBaseQueueLast.next = newBaseQueueFirst); + queue.baseState = newBaseState; + queue.baseQueue = newBaseQueueLast; + markUnprocessedUpdateTime(newExpirationTime); + workInProgress$jscomp$0.expirationTime = newExpirationTime; + workInProgress$jscomp$0.memoizedState = newState; } - null === newFirstUpdate && (queue.lastUpdate = null); - null === updateExpirationTime - ? (queue.lastCapturedUpdate = null) - : (workInProgress.effectTag |= 32); - null === newFirstUpdate && - null === updateExpirationTime && - (newBaseState = resultState); - queue.baseState = newBaseState; - queue.firstUpdate = newFirstUpdate; - queue.firstCapturedUpdate = updateExpirationTime; - markUnprocessedUpdateTime(newExpirationTime); - workInProgress.expirationTime = newExpirationTime; - workInProgress.memoizedState = resultState; } function commitUpdateQueue(finishedWork, finishedQueue, instance) { - null !== finishedQueue.firstCapturedUpdate && - (null !== finishedQueue.lastUpdate && - ((finishedQueue.lastUpdate.next = finishedQueue.firstCapturedUpdate), - (finishedQueue.lastUpdate = finishedQueue.lastCapturedUpdate)), - (finishedQueue.firstCapturedUpdate = finishedQueue.lastCapturedUpdate = null)); - commitUpdateEffects(finishedQueue.firstEffect, instance); - finishedQueue.firstEffect = finishedQueue.lastEffect = null; - commitUpdateEffects(finishedQueue.firstCapturedEffect, instance); - finishedQueue.firstCapturedEffect = finishedQueue.lastCapturedEffect = null; -} -function commitUpdateEffects(effect, instance) { - for (; null !== effect; ) { - var callback = effect.callback; - if (null !== callback) { - effect.callback = null; - if ("function" !== typeof callback) - throw Error( - "Invalid argument passed as callback. Expected a function. Instead received: " + - callback - ); - callback.call(instance); + finishedWork = finishedQueue.effects; + finishedQueue.effects = null; + if (null !== finishedWork) + for ( + finishedQueue = 0; + finishedQueue < finishedWork.length; + finishedQueue++ + ) { + var effect = finishedWork[finishedQueue], + callback = effect.callback; + if (null !== callback) { + effect.callback = null; + if ("function" !== typeof callback) + throw Error( + "Invalid argument passed as callback. Expected a function. Instead received: " + + callback + ); + callback.call(instance); + } } - effect = effect.nextEffect; - } } var ReactCurrentBatchConfig = ReactSharedInternals.ReactCurrentBatchConfig, emptyRefsObject = new React.Component().refs; @@ -2264,10 +2193,8 @@ function applyDerivedStateFromProps( ? ctor : Object.assign({}, ctor, getDerivedStateFromProps); workInProgress.memoizedState = getDerivedStateFromProps; - nextProps = workInProgress.updateQueue; - null !== nextProps && - 0 === workInProgress.expirationTime && - (nextProps.baseState = getDerivedStateFromProps); + 0 === workInProgress.expirationTime && + (workInProgress.updateQueue.baseState = getDerivedStateFromProps); } var classComponentUpdater = { isMounted: function(component) { @@ -2382,6 +2309,7 @@ function mountClassInstance( instance.props = newProps; instance.state = workInProgress.memoizedState; instance.refs = emptyRefsObject; + initializeUpdateQueue(workInProgress); var contextType = ctor.contextType; "object" === typeof contextType && null !== contextType ? (instance.context = readContext(contextType)) @@ -2389,16 +2317,8 @@ function mountClassInstance( ? previousContext : contextStackCursor.current), (instance.context = getMaskedContext(workInProgress, contextType))); - contextType = workInProgress.updateQueue; - null !== contextType && - (processUpdateQueue( - workInProgress, - contextType, - newProps, - instance, - renderExpirationTime - ), - (instance.state = workInProgress.memoizedState)); + processUpdateQueue(workInProgress, newProps, instance, renderExpirationTime); + instance.state = workInProgress.memoizedState; contextType = ctor.getDerivedStateFromProps; "function" === typeof contextType && (applyDerivedStateFromProps(workInProgress, ctor, contextType, newProps), @@ -2414,16 +2334,13 @@ function mountClassInstance( instance.UNSAFE_componentWillMount(), ctor !== instance.state && classComponentUpdater.enqueueReplaceState(instance, instance.state, null), - (contextType = workInProgress.updateQueue), - null !== contextType && - (processUpdateQueue( - workInProgress, - contextType, - newProps, - instance, - renderExpirationTime - ), - (instance.state = workInProgress.memoizedState))); + processUpdateQueue( + workInProgress, + newProps, + instance, + renderExpirationTime + ), + (instance.state = workInProgress.memoizedState)); "function" === typeof instance.componentDidMount && (workInProgress.effectTag |= 4); } @@ -2985,39 +2902,50 @@ function ChildReconciler(shouldTrackSideEffects) { null !== isUnkeyedTopLevelFragment; ) { - if (isUnkeyedTopLevelFragment.key === isObject) - if ( - 7 === isUnkeyedTopLevelFragment.tag - ? newChild.type === REACT_FRAGMENT_TYPE - : isUnkeyedTopLevelFragment.elementType === newChild.type - ) { - deleteRemainingChildren( - returnFiber, - isUnkeyedTopLevelFragment.sibling - ); - currentFirstChild = useFiber( - isUnkeyedTopLevelFragment, - newChild.type === REACT_FRAGMENT_TYPE - ? newChild.props.children - : newChild.props, - expirationTime - ); - currentFirstChild.ref = coerceRef( - returnFiber, - isUnkeyedTopLevelFragment, - newChild - ); - currentFirstChild.return = returnFiber; - returnFiber = currentFirstChild; - break a; - } else { - deleteRemainingChildren( - returnFiber, - isUnkeyedTopLevelFragment - ); - break; + if (isUnkeyedTopLevelFragment.key === isObject) { + switch (isUnkeyedTopLevelFragment.tag) { + case 7: + if (newChild.type === REACT_FRAGMENT_TYPE) { + deleteRemainingChildren( + returnFiber, + isUnkeyedTopLevelFragment.sibling + ); + currentFirstChild = useFiber( + isUnkeyedTopLevelFragment, + newChild.props.children, + expirationTime + ); + currentFirstChild.return = returnFiber; + returnFiber = currentFirstChild; + break a; + } + break; + default: + if ( + isUnkeyedTopLevelFragment.elementType === newChild.type + ) { + deleteRemainingChildren( + returnFiber, + isUnkeyedTopLevelFragment.sibling + ); + currentFirstChild = useFiber( + isUnkeyedTopLevelFragment, + newChild.props, + expirationTime + ); + currentFirstChild.ref = coerceRef( + returnFiber, + isUnkeyedTopLevelFragment, + newChild + ); + currentFirstChild.return = returnFiber; + returnFiber = currentFirstChild; + break a; + } } - else deleteChild(returnFiber, isUnkeyedTopLevelFragment); + deleteRemainingChildren(returnFiber, isUnkeyedTopLevelFragment); + break; + } else deleteChild(returnFiber, isUnkeyedTopLevelFragment); isUnkeyedTopLevelFragment = isUnkeyedTopLevelFragment.sibling; } newChild.type === REACT_FRAGMENT_TYPE @@ -3215,7 +3143,7 @@ function findFirstSuspended(row) { } return null; } -function createResponderListener(responder, props) { +function createDeprecatedResponderListener(responder, props) { return { responder: responder, props: props }; } var ReactCurrentDispatcher$1 = ReactSharedInternals.ReactCurrentDispatcher, @@ -3223,13 +3151,7 @@ var ReactCurrentDispatcher$1 = ReactSharedInternals.ReactCurrentDispatcher, renderExpirationTime$1 = 0, currentlyRenderingFiber$1 = null, currentHook = null, - nextCurrentHook = null, - firstWorkInProgressHook = null, workInProgressHook = null, - nextWorkInProgressHook = null, - remainingExpirationTime = 0, - componentUpdateQueue = null, - sideEffectTag = 0, didScheduleRenderPhaseUpdate = !1, renderPhaseUpdates = null, numberOfReRenders = 0; @@ -3249,53 +3171,45 @@ function renderWithHooks( workInProgress, Component, props, - refOrContext, + secondArg, nextRenderExpirationTime ) { renderExpirationTime$1 = nextRenderExpirationTime; currentlyRenderingFiber$1 = workInProgress; - nextCurrentHook = null !== current ? current.memoizedState : null; + workInProgress.memoizedState = null; + workInProgress.updateQueue = null; + workInProgress.expirationTime = 0; ReactCurrentDispatcher$1.current = - null === nextCurrentHook ? HooksDispatcherOnMount : HooksDispatcherOnUpdate; - workInProgress = Component(props, refOrContext); + null === current || null === current.memoizedState + ? HooksDispatcherOnMount + : HooksDispatcherOnUpdate; + current = Component(props, secondArg); if (didScheduleRenderPhaseUpdate) { do (didScheduleRenderPhaseUpdate = !1), (numberOfReRenders += 1), - (nextCurrentHook = null !== current ? current.memoizedState : null), - (nextWorkInProgressHook = firstWorkInProgressHook), - (componentUpdateQueue = workInProgressHook = currentHook = null), + (workInProgressHook = currentHook = null), + (workInProgress.updateQueue = null), (ReactCurrentDispatcher$1.current = HooksDispatcherOnUpdate), - (workInProgress = Component(props, refOrContext)); + (current = Component(props, secondArg)); while (didScheduleRenderPhaseUpdate); renderPhaseUpdates = null; numberOfReRenders = 0; } ReactCurrentDispatcher$1.current = ContextOnlyDispatcher; - current = currentlyRenderingFiber$1; - current.memoizedState = firstWorkInProgressHook; - current.expirationTime = remainingExpirationTime; - current.updateQueue = componentUpdateQueue; - current.effectTag |= sideEffectTag; - current = null !== currentHook && null !== currentHook.next; + workInProgress = null !== currentHook && null !== currentHook.next; renderExpirationTime$1 = 0; - nextWorkInProgressHook = workInProgressHook = firstWorkInProgressHook = nextCurrentHook = currentHook = currentlyRenderingFiber$1 = null; - remainingExpirationTime = 0; - componentUpdateQueue = null; - sideEffectTag = 0; - if (current) + workInProgressHook = currentHook = currentlyRenderingFiber$1 = null; + if (workInProgress) throw Error( "Rendered fewer hooks than expected. This may be caused by an accidental early return statement." ); - return workInProgress; + return current; } function resetHooks() { ReactCurrentDispatcher$1.current = ContextOnlyDispatcher; renderExpirationTime$1 = 0; - nextWorkInProgressHook = workInProgressHook = firstWorkInProgressHook = nextCurrentHook = currentHook = currentlyRenderingFiber$1 = null; - remainingExpirationTime = 0; - componentUpdateQueue = null; - sideEffectTag = 0; + workInProgressHook = currentHook = currentlyRenderingFiber$1 = null; didScheduleRenderPhaseUpdate = !1; renderPhaseUpdates = null; numberOfReRenders = 0; @@ -3304,37 +3218,42 @@ function mountWorkInProgressHook() { var hook = { memoizedState: null, baseState: null, + baseQueue: null, queue: null, - baseUpdate: null, next: null }; null === workInProgressHook - ? (firstWorkInProgressHook = workInProgressHook = hook) + ? (currentlyRenderingFiber$1.memoizedState = workInProgressHook = hook) : (workInProgressHook = workInProgressHook.next = hook); return workInProgressHook; } function updateWorkInProgressHook() { + if (null === currentHook) { + var nextCurrentHook = currentlyRenderingFiber$1.alternate; + nextCurrentHook = + null !== nextCurrentHook ? nextCurrentHook.memoizedState : null; + } else nextCurrentHook = currentHook.next; + var nextWorkInProgressHook = + null === workInProgressHook + ? currentlyRenderingFiber$1.memoizedState + : workInProgressHook.next; if (null !== nextWorkInProgressHook) (workInProgressHook = nextWorkInProgressHook), - (nextWorkInProgressHook = workInProgressHook.next), - (currentHook = nextCurrentHook), - (nextCurrentHook = null !== currentHook ? currentHook.next : null); + (currentHook = nextCurrentHook); else { if (null === nextCurrentHook) throw Error("Rendered more hooks than during the previous render."); currentHook = nextCurrentHook; - var newHook = { + nextCurrentHook = { memoizedState: currentHook.memoizedState, baseState: currentHook.baseState, + baseQueue: currentHook.baseQueue, queue: currentHook.queue, - baseUpdate: currentHook.baseUpdate, next: null }; - workInProgressHook = - null === workInProgressHook - ? (firstWorkInProgressHook = newHook) - : (workInProgressHook.next = newHook); - nextCurrentHook = currentHook.next; + null === workInProgressHook + ? (currentlyRenderingFiber$1.memoizedState = workInProgressHook = nextCurrentHook) + : (workInProgressHook = workInProgressHook.next = nextCurrentHook); } return workInProgressHook; } @@ -3362,51 +3281,75 @@ function updateReducer(reducer) { while (null !== firstRenderPhaseUpdate); is$1(newState, hook.memoizedState) || (didReceiveUpdate = !0); hook.memoizedState = newState; - hook.baseUpdate === queue.last && (hook.baseState = newState); + null === hook.baseQueue && (hook.baseState = newState); queue.lastRenderedState = newState; return [newState, _dispatch]; } } return [hook.memoizedState, _dispatch]; } - _dispatch = queue.last; - var baseUpdate = hook.baseUpdate; - newState = hook.baseState; - null !== baseUpdate - ? (null !== _dispatch && (_dispatch.next = null), - (_dispatch = baseUpdate.next)) - : (_dispatch = null !== _dispatch ? _dispatch.next : null); + newState = currentHook; + _dispatch = newState.baseQueue; + firstRenderPhaseUpdate = queue.pending; + if (null !== firstRenderPhaseUpdate) { + if (null !== _dispatch) { + var baseFirst = _dispatch.next; + _dispatch.next = firstRenderPhaseUpdate.next; + firstRenderPhaseUpdate.next = baseFirst; + } + newState.baseQueue = _dispatch = firstRenderPhaseUpdate; + queue.pending = null; + } if (null !== _dispatch) { - var newBaseUpdate = (firstRenderPhaseUpdate = null), - _update = _dispatch, - didSkip = !1; + _dispatch = _dispatch.next; + newState = newState.baseState; + var newBaseQueueLast = (baseFirst = firstRenderPhaseUpdate = null), + _update = _dispatch; do { var updateExpirationTime = _update.expirationTime; - updateExpirationTime < renderExpirationTime$1 - ? (didSkip || - ((didSkip = !0), - (newBaseUpdate = baseUpdate), - (firstRenderPhaseUpdate = newState)), - updateExpirationTime > remainingExpirationTime && - ((remainingExpirationTime = updateExpirationTime), - markUnprocessedUpdateTime(remainingExpirationTime))) - : (markRenderEventTimeAndConfig( + if (updateExpirationTime < renderExpirationTime$1) { + var clone = { + expirationTime: _update.expirationTime, + suspenseConfig: _update.suspenseConfig, + action: _update.action, + eagerReducer: _update.eagerReducer, + eagerState: _update.eagerState, + next: null + }; + null === newBaseQueueLast + ? ((baseFirst = newBaseQueueLast = clone), + (firstRenderPhaseUpdate = newState)) + : (newBaseQueueLast = newBaseQueueLast.next = clone); + updateExpirationTime > currentlyRenderingFiber$1.expirationTime && + ((currentlyRenderingFiber$1.expirationTime = updateExpirationTime), + markUnprocessedUpdateTime(updateExpirationTime)); + } else + null !== newBaseQueueLast && + (newBaseQueueLast = newBaseQueueLast.next = { + expirationTime: 1073741823, + suspenseConfig: _update.suspenseConfig, + action: _update.action, + eagerReducer: _update.eagerReducer, + eagerState: _update.eagerState, + next: null + }), + markRenderEventTimeAndConfig( updateExpirationTime, _update.suspenseConfig ), (newState = _update.eagerReducer === reducer ? _update.eagerState - : reducer(newState, _update.action))); - baseUpdate = _update; + : reducer(newState, _update.action)); _update = _update.next; } while (null !== _update && _update !== _dispatch); - didSkip || - ((newBaseUpdate = baseUpdate), (firstRenderPhaseUpdate = newState)); + null === newBaseQueueLast + ? (firstRenderPhaseUpdate = newState) + : (newBaseQueueLast.next = baseFirst); is$1(newState, hook.memoizedState) || (didReceiveUpdate = !0); hook.memoizedState = newState; - hook.baseUpdate = newBaseUpdate; hook.baseState = firstRenderPhaseUpdate; + hook.baseQueue = newBaseQueueLast; queue.lastRenderedState = newState; } return [hook.memoizedState, queue.dispatch]; @@ -3416,7 +3359,7 @@ function mountState(initialState) { "function" === typeof initialState && (initialState = initialState()); hook.memoizedState = hook.baseState = initialState; initialState = hook.queue = { - last: null, + pending: null, dispatch: null, lastRenderedReducer: basicStateReducer, lastRenderedState: initialState @@ -3433,21 +3376,23 @@ function updateState(initialState) { } function pushEffect(tag, create, destroy, deps) { tag = { tag: tag, create: create, destroy: destroy, deps: deps, next: null }; - null === componentUpdateQueue - ? ((componentUpdateQueue = { lastEffect: null }), - (componentUpdateQueue.lastEffect = tag.next = tag)) - : ((create = componentUpdateQueue.lastEffect), - null === create - ? (componentUpdateQueue.lastEffect = tag.next = tag) - : ((destroy = create.next), - (create.next = tag), - (tag.next = destroy), - (componentUpdateQueue.lastEffect = tag))); + create = currentlyRenderingFiber$1.updateQueue; + null === create + ? ((create = { lastEffect: null }), + (currentlyRenderingFiber$1.updateQueue = create), + (create.lastEffect = tag.next = tag)) + : ((destroy = create.lastEffect), + null === destroy + ? (create.lastEffect = tag.next = tag) + : ((deps = destroy.next), + (destroy.next = tag), + (tag.next = deps), + (create.lastEffect = tag))); return tag; } function mountEffectImpl(fiberEffectTag, hookEffectTag, create, deps) { var hook = mountWorkInProgressHook(); - sideEffectTag |= fiberEffectTag; + currentlyRenderingFiber$1.effectTag |= fiberEffectTag; hook.memoizedState = pushEffect( hookEffectTag, create, @@ -3467,7 +3412,7 @@ function updateEffectImpl(fiberEffectTag, hookEffectTag, create, deps) { return; } } - sideEffectTag |= fiberEffectTag; + currentlyRenderingFiber$1.effectTag |= fiberEffectTag; hook.memoizedState = pushEffect(hookEffectTag, create, destroy, deps); } function mountEffect(create, deps) { @@ -3515,6 +3460,21 @@ function updateCallback(callback, deps) { hook.memoizedState = [callback, deps]; return callback; } +function startTransition(setPending, config, callback) { + var priorityLevel = getCurrentPriorityLevel(); + runWithPriority(98 > priorityLevel ? 98 : priorityLevel, function() { + setPending(!0); + }); + runWithPriority(97 < priorityLevel ? 97 : priorityLevel, function() { + var previousConfig = ReactCurrentBatchConfig$1.suspense; + ReactCurrentBatchConfig$1.suspense = void 0 === config ? null : config; + try { + setPending(!1), callback(); + } finally { + ReactCurrentBatchConfig$1.suspense = previousConfig; + } + }); +} function dispatchAction(fiber, queue, action) { if (!(25 > numberOfReRenders)) throw Error( @@ -3556,14 +3516,11 @@ function dispatchAction(fiber, queue, action) { eagerState: null, next: null }; - var last = queue.last; - if (null === last) suspenseConfig.next = suspenseConfig; - else { - var first = last.next; - null !== first && (suspenseConfig.next = first); - last.next = suspenseConfig; - } - queue.last = suspenseConfig; + var pending = queue.pending; + null === pending + ? (suspenseConfig.next = suspenseConfig) + : ((suspenseConfig.next = pending.next), (pending.next = suspenseConfig)); + queue.pending = suspenseConfig; if ( 0 === fiber.expirationTime && (null === alternate || 0 === alternate.expirationTime) && @@ -3626,7 +3583,7 @@ var ContextOnlyDispatcher = { initialArg = void 0 !== init ? init(initialArg) : initialArg; hook.memoizedState = hook.baseState = initialArg; reducer = hook.queue = { - last: null, + pending: null, dispatch: null, lastRenderedReducer: reducer, lastRenderedState: initialArg @@ -3645,23 +3602,21 @@ var ContextOnlyDispatcher = { }, useState: mountState, useDebugValue: mountDebugValue, - useResponder: createResponderListener, + useResponder: createDeprecatedResponderListener, useDeferredValue: function(value, config) { var _mountState = mountState(value), prevValue = _mountState[0], setValue = _mountState[1]; mountEffect( function() { - Scheduler.unstable_next(function() { - var previousConfig = ReactCurrentBatchConfig$1.suspense; - ReactCurrentBatchConfig$1.suspense = - void 0 === config ? null : config; - try { - setValue(value); - } finally { - ReactCurrentBatchConfig$1.suspense = previousConfig; - } - }); + var previousConfig = ReactCurrentBatchConfig$1.suspense; + ReactCurrentBatchConfig$1.suspense = + void 0 === config ? null : config; + try { + setValue(value); + } finally { + ReactCurrentBatchConfig$1.suspense = previousConfig; + } }, [value, config] ); @@ -3669,25 +3624,13 @@ var ContextOnlyDispatcher = { }, useTransition: function(config) { var _mountState2 = mountState(!1), - isPending = _mountState2[0], - setPending = _mountState2[1]; + isPending = _mountState2[0]; + _mountState2 = _mountState2[1]; return [ - mountCallback( - function(callback) { - setPending(!0); - Scheduler.unstable_next(function() { - var previousConfig = ReactCurrentBatchConfig$1.suspense; - ReactCurrentBatchConfig$1.suspense = - void 0 === config ? null : config; - try { - setPending(!1), callback(); - } finally { - ReactCurrentBatchConfig$1.suspense = previousConfig; - } - }); - }, - [config, isPending] - ), + mountCallback(startTransition.bind(null, _mountState2, config), [ + _mountState2, + config + ]), isPending ]; } @@ -3729,23 +3672,21 @@ var ContextOnlyDispatcher = { }, useState: updateState, useDebugValue: mountDebugValue, - useResponder: createResponderListener, + useResponder: createDeprecatedResponderListener, useDeferredValue: function(value, config) { var _updateState = updateState(value), prevValue = _updateState[0], setValue = _updateState[1]; updateEffect( function() { - Scheduler.unstable_next(function() { - var previousConfig = ReactCurrentBatchConfig$1.suspense; - ReactCurrentBatchConfig$1.suspense = - void 0 === config ? null : config; - try { - setValue(value); - } finally { - ReactCurrentBatchConfig$1.suspense = previousConfig; - } - }); + var previousConfig = ReactCurrentBatchConfig$1.suspense; + ReactCurrentBatchConfig$1.suspense = + void 0 === config ? null : config; + try { + setValue(value); + } finally { + ReactCurrentBatchConfig$1.suspense = previousConfig; + } }, [value, config] ); @@ -3753,25 +3694,13 @@ var ContextOnlyDispatcher = { }, useTransition: function(config) { var _updateState2 = updateState(!1), - isPending = _updateState2[0], - setPending = _updateState2[1]; + isPending = _updateState2[0]; + _updateState2 = _updateState2[1]; return [ - updateCallback( - function(callback) { - setPending(!0); - Scheduler.unstable_next(function() { - var previousConfig = ReactCurrentBatchConfig$1.suspense; - ReactCurrentBatchConfig$1.suspense = - void 0 === config ? null : config; - try { - setPending(!1), callback(); - } finally { - ReactCurrentBatchConfig$1.suspense = previousConfig; - } - }); - }, - [config, isPending] - ), + updateCallback(startTransition.bind(null, _updateState2, config), [ + _updateState2, + config + ]), isPending ]; } @@ -4085,17 +4014,14 @@ function updateClassComponent( )); hasForceUpdate = !1; var oldState = workInProgress.memoizedState; - oldContext = instance.state = oldState; - var updateQueue = workInProgress.updateQueue; - null !== updateQueue && - (processUpdateQueue( - workInProgress, - updateQueue, - nextProps, - instance, - renderExpirationTime - ), - (oldContext = workInProgress.memoizedState)); + instance.state = oldState; + processUpdateQueue( + workInProgress, + nextProps, + instance, + renderExpirationTime + ); + oldContext = workInProgress.memoizedState; oldProps !== nextProps || oldState !== oldContext || didPerformWorkStackCursor.current || @@ -4141,6 +4067,7 @@ function updateClassComponent( (nextProps = !1)); } else (instance = workInProgress.stateNode), + cloneUpdateQueue(current$$1, workInProgress), (oldProps = workInProgress.memoizedProps), (instance.props = workInProgress.type === workInProgress.elementType @@ -4169,17 +4096,14 @@ function updateClassComponent( )), (hasForceUpdate = !1), (oldContext = workInProgress.memoizedState), - (oldState = instance.state = oldContext), - (updateQueue = workInProgress.updateQueue), - null !== updateQueue && - (processUpdateQueue( - workInProgress, - updateQueue, - nextProps, - instance, - renderExpirationTime - ), - (oldState = workInProgress.memoizedState)), + (instance.state = oldContext), + processUpdateQueue( + workInProgress, + nextProps, + instance, + renderExpirationTime + ), + (oldState = workInProgress.memoizedState), oldProps !== nextProps || oldContext !== oldState || didPerformWorkStackCursor.current || @@ -4481,6 +4405,7 @@ function initSuspenseListRenderState( ? (workInProgress.memoizedState = { isBackwards: isBackwards, rendering: null, + renderingStartTime: 0, last: lastContentRow, tail: tail, tailExpiration: 0, @@ -4489,6 +4414,7 @@ function initSuspenseListRenderState( }) : ((renderState.isBackwards = isBackwards), (renderState.rendering = null), + (renderState.renderingStartTime = 0), (renderState.last = lastContentRow), (renderState.tail = tail), (renderState.tailExpiration = 0), @@ -4695,38 +4621,348 @@ function cutOffTailIfNeeded(renderState, hasRenderedATailFallback) { : (_lastTailNode.sibling = null); } } -function unwindWork(workInProgress) { +function completeWork(current, workInProgress, renderExpirationTime$jscomp$0) { + 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 null; case 1: - isContextProvider(workInProgress.type) && popContext(workInProgress); - var effectTag = workInProgress.effectTag; - return effectTag & 4096 - ? ((workInProgress.effectTag = (effectTag & -4097) | 64), - workInProgress) - : null; + return ( + isContextProvider(workInProgress.type) && popContext(workInProgress), + null + ); case 3: - popHostContainer(workInProgress); - popTopLevelContextObject(workInProgress); - effectTag = workInProgress.effectTag; - if (0 !== (effectTag & 64)) - throw Error( - "The root failed to unmount after an error. This is likely a bug in React. Please file an issue." - ); - workInProgress.effectTag = (effectTag & -4097) | 64; - return workInProgress; + return ( + popHostContainer(workInProgress), + popTopLevelContextObject(workInProgress), + (current = workInProgress.stateNode), + current.pendingContext && + ((current.context = current.pendingContext), + (current.pendingContext = null)), + updateHostContainer(workInProgress), + null + ); case 5: - return popHostContext(workInProgress), null; + popHostContext(workInProgress); + var rootContainerInstance = requiredContext( + rootInstanceStackCursor.current + ); + renderExpirationTime$jscomp$0 = workInProgress.type; + if (null !== current && null != workInProgress.stateNode) + updateHostComponent$1( + current, + workInProgress, + renderExpirationTime$jscomp$0, + newProps, + rootContainerInstance + ), + current.ref !== workInProgress.ref && + (workInProgress.effectTag |= 128); + 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." + ); + return null; + } + current = requiredContext(contextStackCursor$1.current); + var tag = allocateTag(), + viewConfig = getViewConfigForType(renderExpirationTime$jscomp$0), + updatePayload = diffProperties( + null, + emptyObject, + newProps, + viewConfig.validAttributes + ); + ReactNativePrivateInterface.UIManager.createView( + tag, + viewConfig.uiViewClassName, + rootContainerInstance, + updatePayload + ); + viewConfig = new ReactNativeFiberHostComponent(tag, viewConfig); + instanceCache.set(tag, workInProgress); + instanceProps.set(tag, newProps); + appendAllChildren(viewConfig, workInProgress, !1, !1); + workInProgress.stateNode = viewConfig; + finalizeInitialChildren( + viewConfig, + renderExpirationTime$jscomp$0, + newProps, + rootContainerInstance, + current + ) && (workInProgress.effectTag |= 4); + null !== workInProgress.ref && (workInProgress.effectTag |= 128); + } + 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." + ); + rootContainerInstance = allocateTag(); + ReactNativePrivateInterface.UIManager.createView( + rootContainerInstance, + "RCTRawText", + current, + { text: newProps } + ); + instanceCache.set(rootContainerInstance, workInProgress); + workInProgress.stateNode = rootContainerInstance; + } + return null; case 13: + pop(suspenseStackCursor, workInProgress); + newProps = workInProgress.memoizedState; + if (0 !== (workInProgress.effectTag & 64)) + return ( + (workInProgress.expirationTime = renderExpirationTime$jscomp$0), + workInProgress + ); + newProps = null !== newProps; + rootContainerInstance = !1; + null !== current && + ((renderExpirationTime$jscomp$0 = current.memoizedState), + (rootContainerInstance = null !== renderExpirationTime$jscomp$0), + newProps || + null === renderExpirationTime$jscomp$0 || + ((renderExpirationTime$jscomp$0 = current.child.sibling), + null !== renderExpirationTime$jscomp$0 && + ((tag = workInProgress.firstEffect), + null !== tag + ? ((workInProgress.firstEffect = renderExpirationTime$jscomp$0), + (renderExpirationTime$jscomp$0.nextEffect = tag)) + : ((workInProgress.firstEffect = workInProgress.lastEffect = renderExpirationTime$jscomp$0), + (renderExpirationTime$jscomp$0.nextEffect = null)), + (renderExpirationTime$jscomp$0.effectTag = 8)))); + if (newProps && !rootContainerInstance && 0 !== (workInProgress.mode & 2)) + if ( + (null === current && + !0 !== workInProgress.memoizedProps.unstable_avoidThisFallback) || + 0 !== (suspenseStackCursor.current & 1) + ) + workInProgressRootExitStatus === RootIncomplete && + (workInProgressRootExitStatus = RootSuspended); + else { + if ( + workInProgressRootExitStatus === RootIncomplete || + workInProgressRootExitStatus === RootSuspended + ) + workInProgressRootExitStatus = RootSuspendedWithDelay; + 0 !== workInProgressRootNextUnprocessedUpdateTime && + null !== workInProgressRoot && + (markRootSuspendedAtTime(workInProgressRoot, renderExpirationTime), + markRootUpdatedAtTime( + workInProgressRoot, + workInProgressRootNextUnprocessedUpdateTime + )); + } + if (newProps || rootContainerInstance) workInProgress.effectTag |= 4; + return null; + case 4: return ( - pop(suspenseStackCursor, workInProgress), - (effectTag = workInProgress.effectTag), - effectTag & 4096 - ? ((workInProgress.effectTag = (effectTag & -4097) | 64), - workInProgress) - : null + popHostContainer(workInProgress), + updateHostContainer(workInProgress), + null ); - case 19: - return pop(suspenseStackCursor, workInProgress), null; + case 10: + return popProvider(workInProgress), null; + case 17: + return ( + isContextProvider(workInProgress.type) && popContext(workInProgress), + null + ); + case 19: + pop(suspenseStackCursor, workInProgress); + newProps = workInProgress.memoizedState; + if (null === newProps) return null; + rootContainerInstance = 0 !== (workInProgress.effectTag & 64); + tag = newProps.rendering; + if (null === tag) + if (rootContainerInstance) cutOffTailIfNeeded(newProps, !1); + else { + if ( + workInProgressRootExitStatus !== RootIncomplete || + (null !== current && 0 !== (current.effectTag & 64)) + ) + for (current = workInProgress.child; null !== current; ) { + tag = findFirstSuspended(current); + if (null !== tag) { + workInProgress.effectTag |= 64; + cutOffTailIfNeeded(newProps, !1); + current = tag.updateQueue; + null !== current && + ((workInProgress.updateQueue = current), + (workInProgress.effectTag |= 4)); + null === newProps.lastEffect && + (workInProgress.firstEffect = null); + workInProgress.lastEffect = newProps.lastEffect; + current = renderExpirationTime$jscomp$0; + for (newProps = workInProgress.child; null !== newProps; ) + (rootContainerInstance = newProps), + (renderExpirationTime$jscomp$0 = current), + (rootContainerInstance.effectTag &= 2), + (rootContainerInstance.nextEffect = null), + (rootContainerInstance.firstEffect = null), + (rootContainerInstance.lastEffect = null), + (tag = rootContainerInstance.alternate), + null === tag + ? ((rootContainerInstance.childExpirationTime = 0), + (rootContainerInstance.expirationTime = renderExpirationTime$jscomp$0), + (rootContainerInstance.child = null), + (rootContainerInstance.memoizedProps = null), + (rootContainerInstance.memoizedState = null), + (rootContainerInstance.updateQueue = null), + (rootContainerInstance.dependencies = null)) + : ((rootContainerInstance.childExpirationTime = + tag.childExpirationTime), + (rootContainerInstance.expirationTime = + tag.expirationTime), + (rootContainerInstance.child = tag.child), + (rootContainerInstance.memoizedProps = + tag.memoizedProps), + (rootContainerInstance.memoizedState = + tag.memoizedState), + (rootContainerInstance.updateQueue = tag.updateQueue), + (renderExpirationTime$jscomp$0 = tag.dependencies), + (rootContainerInstance.dependencies = + null === renderExpirationTime$jscomp$0 + ? null + : { + expirationTime: + renderExpirationTime$jscomp$0.expirationTime, + firstContext: + renderExpirationTime$jscomp$0.firstContext, + responders: + renderExpirationTime$jscomp$0.responders + })), + (newProps = newProps.sibling); + push( + suspenseStackCursor, + (suspenseStackCursor.current & 1) | 2, + workInProgress + ); + return workInProgress.child; + } + current = current.sibling; + } + } + else { + if (!rootContainerInstance) + if (((current = findFirstSuspended(tag)), null !== current)) { + if ( + ((workInProgress.effectTag |= 64), + (rootContainerInstance = !0), + (current = current.updateQueue), + null !== current && + ((workInProgress.updateQueue = current), + (workInProgress.effectTag |= 4)), + cutOffTailIfNeeded(newProps, !0), + null === newProps.tail && + "hidden" === newProps.tailMode && + !tag.alternate) + ) + return ( + (workInProgress = workInProgress.lastEffect = + newProps.lastEffect), + null !== workInProgress && (workInProgress.nextEffect = null), + null + ); + } else + 2 * now() - newProps.renderingStartTime > newProps.tailExpiration && + 1 < renderExpirationTime$jscomp$0 && + ((workInProgress.effectTag |= 64), + (rootContainerInstance = !0), + cutOffTailIfNeeded(newProps, !1), + (workInProgress.expirationTime = workInProgress.childExpirationTime = + renderExpirationTime$jscomp$0 - 1)); + newProps.isBackwards + ? ((tag.sibling = workInProgress.child), (workInProgress.child = tag)) + : ((current = newProps.last), + null !== current + ? (current.sibling = tag) + : (workInProgress.child = tag), + (newProps.last = tag)); + } + return null !== newProps.tail + ? (0 === newProps.tailExpiration && + (newProps.tailExpiration = now() + 500), + (current = newProps.tail), + (newProps.rendering = current), + (newProps.tail = current.sibling), + (newProps.lastEffect = workInProgress.lastEffect), + (newProps.renderingStartTime = now()), + (current.sibling = null), + (newProps = suspenseStackCursor.current), + push( + suspenseStackCursor, + rootContainerInstance ? (newProps & 1) | 2 : newProps & 1, + workInProgress + ), + current) + : null; + } + throw 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) { + switch (workInProgress.tag) { + case 1: + isContextProvider(workInProgress.type) && popContext(workInProgress); + var effectTag = workInProgress.effectTag; + return effectTag & 4096 + ? ((workInProgress.effectTag = (effectTag & -4097) | 64), + workInProgress) + : null; + case 3: + popHostContainer(workInProgress); + popTopLevelContextObject(workInProgress); + effectTag = workInProgress.effectTag; + if (0 !== (effectTag & 64)) + throw Error( + "The root failed to unmount after an error. This is likely a bug in React. Please file an issue." + ); + workInProgress.effectTag = (effectTag & -4097) | 64; + return workInProgress; + case 5: + return popHostContext(workInProgress), null; + case 13: + return ( + pop(suspenseStackCursor, workInProgress), + (effectTag = workInProgress.effectTag), + effectTag & 4096 + ? ((workInProgress.effectTag = (effectTag & -4097) | 64), + workInProgress) + : null + ); + case 19: + return pop(suspenseStackCursor, workInProgress), null; case 4: return popHostContainer(workInProgress), null; case 10: @@ -4810,8 +5046,9 @@ function commitBeforeMutationLifeCycles(current$$1, finishedWork) { case 0: case 11: case 15: + case 22: commitHookEffectList(2, 0, finishedWork); - break; + return; case 1: if (finishedWork.effectTag & 256 && null !== current$$1) { var prevProps = current$$1.memoizedProps, @@ -4825,18 +5062,17 @@ function commitBeforeMutationLifeCycles(current$$1, finishedWork) { ); current$$1.__reactInternalSnapshotBeforeUpdate = finishedWork; } - break; + return; case 3: case 5: case 6: case 4: case 17: - 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." - ); + return; } + throw Error( + "This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue." + ); } function commitHookEffectList(unmountTag, mountTag, finishedWork) { finishedWork = finishedWork.updateQueue; @@ -4855,6 +5091,86 @@ function commitHookEffectList(unmountTag, mountTag, finishedWork) { } while (effect !== finishedWork); } } +function commitLifeCycles( + finishedRoot, + current$$1, + finishedWork, + committedExpirationTime +) { + switch (finishedWork.tag) { + case 0: + case 11: + case 15: + case 22: + commitHookEffectList(16, 32, finishedWork); + return; + case 1: + finishedRoot = finishedWork.stateNode; + if (finishedWork.effectTag & 4) + if (null === current$$1) finishedRoot.componentDidMount(); + else { + var prevProps = + finishedWork.elementType === finishedWork.type + ? current$$1.memoizedProps + : resolveDefaultProps( + finishedWork.type, + current$$1.memoizedProps + ); + finishedRoot.componentDidUpdate( + prevProps, + current$$1.memoizedState, + finishedRoot.__reactInternalSnapshotBeforeUpdate + ); + } + current$$1 = finishedWork.updateQueue; + null !== current$$1 && + commitUpdateQueue( + finishedWork, + current$$1, + finishedRoot, + committedExpirationTime + ); + return; + case 3: + current$$1 = finishedWork.updateQueue; + if (null !== current$$1) { + finishedRoot = null; + if (null !== finishedWork.child) + switch (finishedWork.child.tag) { + case 5: + finishedRoot = finishedWork.child.stateNode; + break; + case 1: + finishedRoot = finishedWork.child.stateNode; + } + commitUpdateQueue( + finishedWork, + current$$1, + finishedRoot, + committedExpirationTime + ); + } + return; + case 5: + return; + case 6: + return; + case 4: + return; + case 12: + return; + case 13: + return; + case 19: + case 17: + case 20: + case 21: + return; + } + throw Error( + "This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue." + ); +} function commitUnmount(finishedRoot, current$$1$jscomp$0, renderPriorityLevel) { "function" === typeof onCommitFiberUnmount && onCommitFiberUnmount(current$$1$jscomp$0); @@ -4863,6 +5179,7 @@ function commitUnmount(finishedRoot, current$$1$jscomp$0, renderPriorityLevel) { case 11: case 14: case 15: + case 22: finishedRoot = current$$1$jscomp$0.updateQueue; if ( null !== finishedRoot && @@ -4921,6 +5238,7 @@ function detachFiber(current$$1) { current$$1.lastEffect = null; current$$1.pendingProps = null; current$$1.memoizedProps = null; + current$$1.stateNode = null; null !== alternate && detachFiber(alternate); } function isHostParent(fiber) { @@ -5187,10 +5505,11 @@ function commitWork(current$$1, finishedWork) { case 11: case 14: case 15: + case 22: commitHookEffectList(4, 8, finishedWork); - break; + return; case 1: - break; + return; case 5: var instance = finishedWork.stateNode; if (null != instance) { @@ -5214,7 +5533,7 @@ function commitWork(current$$1, finishedWork) { newProps )); } - break; + return; case 6: if (null === finishedWork.stateNode) throw Error( @@ -5225,11 +5544,11 @@ function commitWork(current$$1, finishedWork) { "RCTRawText", { text: finishedWork.memoizedProps } ); - break; + return; case 3: - break; + return; case 12: - break; + return; case 13: instance = finishedWork; null === finishedWork.memoizedState @@ -5299,21 +5618,16 @@ function commitWork(current$$1, finishedWork) { current$$1 = current$$1.sibling; } attachSuspenseRetryListeners(finishedWork); - break; + return; case 19: attachSuspenseRetryListeners(finishedWork); - break; + return; case 17: - break; - case 20: - break; - case 21: - 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." - ); + return; } + throw Error( + "This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue." + ); } function attachSuspenseRetryListeners(finishedWork) { var thenables = finishedWork.updateQueue; @@ -5785,44 +6099,41 @@ function performConcurrentWorkOnRoot(root, didTimeout) { function performSyncWorkOnRoot(root) { var lastExpiredTime = root.lastExpiredTime; lastExpiredTime = 0 !== lastExpiredTime ? lastExpiredTime : 1073741823; - if (root.finishedExpirationTime === lastExpiredTime) commitRoot(root); - else { - if ((executionContext & (RenderContext | CommitContext)) !== NoContext) - throw Error("Should not already be working."); - flushPassiveEffects(); - (root === workInProgressRoot && lastExpiredTime === renderExpirationTime) || - prepareFreshStack(root, lastExpiredTime); - if (null !== workInProgress) { - var prevExecutionContext = executionContext; - executionContext |= RenderContext; - var prevDispatcher = pushDispatcher(root); - do - try { - workLoopSync(); - break; - } catch (thrownValue) { - handleError(root, thrownValue); - } - while (1); - resetContextDependencies(); - executionContext = prevExecutionContext; - ReactCurrentDispatcher.current = prevDispatcher; - if (workInProgressRootExitStatus === RootFatalErrored) - throw ((prevExecutionContext = workInProgressRootFatalError), - prepareFreshStack(root, lastExpiredTime), - markRootSuspendedAtTime(root, lastExpiredTime), - ensureRootIsScheduled(root), - prevExecutionContext); - if (null !== workInProgress) - throw Error( - "Cannot commit an incomplete root. This error is likely caused by a bug in React. Please file an issue." - ); - root.finishedWork = root.current.alternate; - root.finishedExpirationTime = lastExpiredTime; - workInProgressRoot = null; - commitRoot(root); - ensureRootIsScheduled(root); - } + if ((executionContext & (RenderContext | CommitContext)) !== NoContext) + throw Error("Should not already be working."); + flushPassiveEffects(); + (root === workInProgressRoot && lastExpiredTime === renderExpirationTime) || + prepareFreshStack(root, lastExpiredTime); + if (null !== workInProgress) { + var prevExecutionContext = executionContext; + executionContext |= RenderContext; + var prevDispatcher = pushDispatcher(root); + do + try { + workLoopSync(); + break; + } catch (thrownValue) { + handleError(root, thrownValue); + } + while (1); + resetContextDependencies(); + executionContext = prevExecutionContext; + ReactCurrentDispatcher.current = prevDispatcher; + if (workInProgressRootExitStatus === RootFatalErrored) + throw ((prevExecutionContext = workInProgressRootFatalError), + prepareFreshStack(root, lastExpiredTime), + markRootSuspendedAtTime(root, lastExpiredTime), + ensureRootIsScheduled(root), + prevExecutionContext); + if (null !== workInProgress) + throw Error( + "Cannot commit an incomplete root. This error is likely caused by a bug in React. Please file an issue." + ); + root.finishedWork = root.current.alternate; + root.finishedExpirationTime = lastExpiredTime; + workInProgressRoot = null; + commitRoot(root); + ensureRootIsScheduled(root); } return null; } @@ -5908,8 +6219,15 @@ function handleError(root$jscomp$0, thrownValue) { "object" === typeof value && "function" === typeof value.then ) { - var thenable = value, - hasInvisibleParentBoundary = + var thenable = value; + if (0 === (sourceFiber.mode & 2)) { + var currentSource = sourceFiber.alternate; + currentSource + ? ((sourceFiber.memoizedState = currentSource.memoizedState), + (sourceFiber.expirationTime = currentSource.expirationTime)) + : (sourceFiber.memoizedState = null); + } + var hasInvisibleParentBoundary = 0 !== (suspenseStackCursor.current & 1), _workInProgress = returnFiber; do { @@ -6077,361 +6395,30 @@ function completeUnitOfWork(unitOfWork) { var current$$1 = workInProgress.alternate; unitOfWork = workInProgress.return; if (0 === (workInProgress.effectTag & 2048)) { - a: { - var current = current$$1; - current$$1 = workInProgress; - var renderExpirationTime$jscomp$0 = renderExpirationTime, - newProps = current$$1.pendingProps; - switch (current$$1.tag) { - case 2: - break; - case 16: - break; - case 15: - case 0: - break; - case 1: - isContextProvider(current$$1.type) && popContext(current$$1); - break; - case 3: - popHostContainer(current$$1); - popTopLevelContextObject(current$$1); - current = current$$1.stateNode; - current.pendingContext && - ((current.context = current.pendingContext), - (current.pendingContext = null)); - updateHostContainer(current$$1); - break; - case 5: - popHostContext(current$$1); - var rootContainerInstance = requiredContext( - rootInstanceStackCursor.current - ); - renderExpirationTime$jscomp$0 = current$$1.type; - if (null !== current && null != current$$1.stateNode) - updateHostComponent$1( - current, - current$$1, - renderExpirationTime$jscomp$0, - newProps, - rootContainerInstance - ), - current.ref !== current$$1.ref && (current$$1.effectTag |= 128); - else if (newProps) { - current = requiredContext(contextStackCursor$1.current); - var internalInstanceHandle = current$$1, - tag = allocateTag(), - viewConfig = getViewConfigForType( - renderExpirationTime$jscomp$0 - ), - updatePayload = diffProperties( - null, - emptyObject, - newProps, - viewConfig.validAttributes - ); - ReactNativePrivateInterface.UIManager.createView( - tag, - viewConfig.uiViewClassName, - rootContainerInstance, - updatePayload - ); - viewConfig = new ReactNativeFiberHostComponent(tag, viewConfig); - instanceCache.set(tag, internalInstanceHandle); - instanceProps.set(tag, newProps); - appendAllChildren(viewConfig, current$$1, !1, !1); - current$$1.stateNode = viewConfig; - finalizeInitialChildren( - viewConfig, - renderExpirationTime$jscomp$0, - newProps, - rootContainerInstance, - current - ) && (current$$1.effectTag |= 4); - null !== current$$1.ref && (current$$1.effectTag |= 128); - } else if (null === current$$1.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." - ); - break; - case 6: - if (current && null != current$$1.stateNode) - updateHostText$1( - current, - current$$1, - current.memoizedProps, - newProps - ); - else { - if ("string" !== typeof newProps && null === current$$1.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." - ); - renderExpirationTime$jscomp$0 = requiredContext( - rootInstanceStackCursor.current - ); - rootContainerInstance = requiredContext( - contextStackCursor$1.current - ); - current = current$$1; - if (!rootContainerInstance.isInAParentText) - throw Error( - "Text strings must be rendered within a component." - ); - rootContainerInstance = allocateTag(); - ReactNativePrivateInterface.UIManager.createView( - rootContainerInstance, - "RCTRawText", - renderExpirationTime$jscomp$0, - { text: newProps } - ); - instanceCache.set(rootContainerInstance, current$$1); - current.stateNode = rootContainerInstance; - } - break; - case 11: - break; - case 13: - pop(suspenseStackCursor, current$$1); - newProps = current$$1.memoizedState; - if (0 !== (current$$1.effectTag & 64)) { - current$$1.expirationTime = renderExpirationTime$jscomp$0; - break a; - } - newProps = null !== newProps; - rootContainerInstance = !1; - null !== current && - ((renderExpirationTime$jscomp$0 = current.memoizedState), - (rootContainerInstance = null !== renderExpirationTime$jscomp$0), - newProps || - null === renderExpirationTime$jscomp$0 || - ((renderExpirationTime$jscomp$0 = current.child.sibling), - null !== renderExpirationTime$jscomp$0 && - ((internalInstanceHandle = current$$1.firstEffect), - null !== internalInstanceHandle - ? ((current$$1.firstEffect = renderExpirationTime$jscomp$0), - (renderExpirationTime$jscomp$0.nextEffect = internalInstanceHandle)) - : ((current$$1.firstEffect = current$$1.lastEffect = renderExpirationTime$jscomp$0), - (renderExpirationTime$jscomp$0.nextEffect = null)), - (renderExpirationTime$jscomp$0.effectTag = 8)))); - if ( - newProps && - !rootContainerInstance && - 0 !== (current$$1.mode & 2) - ) - if ( - (null === current && - !0 !== current$$1.memoizedProps.unstable_avoidThisFallback) || - 0 !== (suspenseStackCursor.current & 1) - ) - workInProgressRootExitStatus === RootIncomplete && - (workInProgressRootExitStatus = RootSuspended); - else { - if ( - workInProgressRootExitStatus === RootIncomplete || - workInProgressRootExitStatus === RootSuspended - ) - workInProgressRootExitStatus = RootSuspendedWithDelay; - 0 !== workInProgressRootNextUnprocessedUpdateTime && - null !== workInProgressRoot && - (markRootSuspendedAtTime( - workInProgressRoot, - renderExpirationTime - ), - markRootUpdatedAtTime( - workInProgressRoot, - workInProgressRootNextUnprocessedUpdateTime - )); - } - if (newProps || rootContainerInstance) current$$1.effectTag |= 4; - break; - case 7: - break; - case 8: - break; - case 12: - break; - case 4: - popHostContainer(current$$1); - updateHostContainer(current$$1); - break; - case 10: - popProvider(current$$1); - break; - case 9: - break; - case 14: - break; - case 17: - isContextProvider(current$$1.type) && popContext(current$$1); - break; - case 19: - pop(suspenseStackCursor, current$$1); - newProps = current$$1.memoizedState; - if (null === newProps) break; - rootContainerInstance = 0 !== (current$$1.effectTag & 64); - internalInstanceHandle = newProps.rendering; - if (null === internalInstanceHandle) - if (rootContainerInstance) cutOffTailIfNeeded(newProps, !1); - else { - if ( - workInProgressRootExitStatus !== RootIncomplete || - (null !== current && 0 !== (current.effectTag & 64)) - ) - for (current = current$$1.child; null !== current; ) { - internalInstanceHandle = findFirstSuspended(current); - if (null !== internalInstanceHandle) { - current$$1.effectTag |= 64; - cutOffTailIfNeeded(newProps, !1); - current = internalInstanceHandle.updateQueue; - null !== current && - ((current$$1.updateQueue = current), - (current$$1.effectTag |= 4)); - null === newProps.lastEffect && - (current$$1.firstEffect = null); - current$$1.lastEffect = newProps.lastEffect; - current = renderExpirationTime$jscomp$0; - for (newProps = current$$1.child; null !== newProps; ) - (rootContainerInstance = newProps), - (renderExpirationTime$jscomp$0 = current), - (rootContainerInstance.effectTag &= 2), - (rootContainerInstance.nextEffect = null), - (rootContainerInstance.firstEffect = null), - (rootContainerInstance.lastEffect = null), - (internalInstanceHandle = - rootContainerInstance.alternate), - null === internalInstanceHandle - ? ((rootContainerInstance.childExpirationTime = 0), - (rootContainerInstance.expirationTime = renderExpirationTime$jscomp$0), - (rootContainerInstance.child = null), - (rootContainerInstance.memoizedProps = null), - (rootContainerInstance.memoizedState = null), - (rootContainerInstance.updateQueue = null), - (rootContainerInstance.dependencies = null)) - : ((rootContainerInstance.childExpirationTime = - internalInstanceHandle.childExpirationTime), - (rootContainerInstance.expirationTime = - internalInstanceHandle.expirationTime), - (rootContainerInstance.child = - internalInstanceHandle.child), - (rootContainerInstance.memoizedProps = - internalInstanceHandle.memoizedProps), - (rootContainerInstance.memoizedState = - internalInstanceHandle.memoizedState), - (rootContainerInstance.updateQueue = - internalInstanceHandle.updateQueue), - (renderExpirationTime$jscomp$0 = - internalInstanceHandle.dependencies), - (rootContainerInstance.dependencies = - null === renderExpirationTime$jscomp$0 - ? null - : { - expirationTime: - renderExpirationTime$jscomp$0.expirationTime, - firstContext: - renderExpirationTime$jscomp$0.firstContext, - responders: - renderExpirationTime$jscomp$0.responders - })), - (newProps = newProps.sibling); - push( - suspenseStackCursor, - (suspenseStackCursor.current & 1) | 2, - current$$1 - ); - current$$1 = current$$1.child; - break a; - } - current = current.sibling; - } - } - else { - if (!rootContainerInstance) - if ( - ((current = findFirstSuspended(internalInstanceHandle)), - null !== current) - ) { - if ( - ((current$$1.effectTag |= 64), - (rootContainerInstance = !0), - (current = current.updateQueue), - null !== current && - ((current$$1.updateQueue = current), - (current$$1.effectTag |= 4)), - cutOffTailIfNeeded(newProps, !0), - null === newProps.tail && - "hidden" === newProps.tailMode && - !internalInstanceHandle.alternate) - ) { - current$$1 = current$$1.lastEffect = newProps.lastEffect; - null !== current$$1 && (current$$1.nextEffect = null); - break; - } - } else - now() > newProps.tailExpiration && - 1 < renderExpirationTime$jscomp$0 && - ((current$$1.effectTag |= 64), - (rootContainerInstance = !0), - cutOffTailIfNeeded(newProps, !1), - (current$$1.expirationTime = current$$1.childExpirationTime = - renderExpirationTime$jscomp$0 - 1)); - newProps.isBackwards - ? ((internalInstanceHandle.sibling = current$$1.child), - (current$$1.child = internalInstanceHandle)) - : ((current = newProps.last), - null !== current - ? (current.sibling = internalInstanceHandle) - : (current$$1.child = internalInstanceHandle), - (newProps.last = internalInstanceHandle)); - } - if (null !== newProps.tail) { - 0 === newProps.tailExpiration && - (newProps.tailExpiration = now() + 500); - current = newProps.tail; - newProps.rendering = current; - newProps.tail = current.sibling; - newProps.lastEffect = current$$1.lastEffect; - current.sibling = null; - newProps = suspenseStackCursor.current; - newProps = rootContainerInstance - ? (newProps & 1) | 2 - : newProps & 1; - push(suspenseStackCursor, newProps, current$$1); - current$$1 = current; - break a; - } - break; - case 20: - break; - case 21: - break; - default: - throw Error( - "Unknown unit of work tag (" + - current$$1.tag + - "). This error is likely caused by a bug in React. Please file an issue." - ); - } - current$$1 = null; - } - current = workInProgress; - if (1 === renderExpirationTime || 1 !== current.childExpirationTime) { - newProps = 0; + current$$1 = completeWork( + current$$1, + workInProgress, + renderExpirationTime + ); + var completedWork = workInProgress; + if ( + 1 === renderExpirationTime || + 1 !== completedWork.childExpirationTime + ) { for ( - rootContainerInstance = current.child; - null !== rootContainerInstance; + var newChildExpirationTime = 0, _child = completedWork.child; + null !== _child; - ) - (renderExpirationTime$jscomp$0 = - rootContainerInstance.expirationTime), - (internalInstanceHandle = - rootContainerInstance.childExpirationTime), - renderExpirationTime$jscomp$0 > newProps && - (newProps = renderExpirationTime$jscomp$0), - internalInstanceHandle > newProps && - (newProps = internalInstanceHandle), - (rootContainerInstance = rootContainerInstance.sibling); - current.childExpirationTime = newProps; + ) { + var _childUpdateExpirationTime = _child.expirationTime, + _childChildExpirationTime = _child.childExpirationTime; + _childUpdateExpirationTime > newChildExpirationTime && + (newChildExpirationTime = _childUpdateExpirationTime); + _childChildExpirationTime > newChildExpirationTime && + (newChildExpirationTime = _childChildExpirationTime); + _child = _child.sibling; + } + completedWork.childExpirationTime = newChildExpirationTime; } if (null !== current$$1) return current$$1; null !== unitOfWork && @@ -6474,7 +6461,8 @@ function commitRoot(root) { return null; } function commitRootImpl(root$jscomp$0, renderPriorityLevel$jscomp$0) { - flushPassiveEffects(); + do flushPassiveEffects(); + while (null !== rootWithPendingPassiveEffects); if ((executionContext & (RenderContext | CommitContext)) !== NoContext) throw Error("Should not already be working."); var finishedWork = root$jscomp$0.finishedWork, @@ -6585,97 +6573,34 @@ function commitRootImpl(root$jscomp$0, renderPriorityLevel$jscomp$0) { nextEffect = remainingExpirationTimeBeforeCommit; do try { - for (effectTag = expirationTime; null !== nextEffect; ) { + for ( + effectTag = root$jscomp$0, current$$1 = expirationTime; + null !== nextEffect; + + ) { var effectTag$jscomp$0 = nextEffect.effectTag; - if (effectTag$jscomp$0 & 36) { - var current$$1$jscomp$1 = nextEffect.alternate; - current$$1 = nextEffect; - currentRef = effectTag; - switch (current$$1.tag) { - case 0: - case 11: - case 15: - commitHookEffectList(16, 32, current$$1); - break; - case 1: - var instance = current$$1.stateNode; - if (current$$1.effectTag & 4) - if (null === current$$1$jscomp$1) - instance.componentDidMount(); - else { - var prevProps = - current$$1.elementType === current$$1.type - ? current$$1$jscomp$1.memoizedProps - : resolveDefaultProps( - current$$1.type, - current$$1$jscomp$1.memoizedProps - ); - instance.componentDidUpdate( - prevProps, - current$$1$jscomp$1.memoizedState, - instance.__reactInternalSnapshotBeforeUpdate - ); - } - var updateQueue = current$$1.updateQueue; - null !== updateQueue && - commitUpdateQueue( - current$$1, - updateQueue, - instance, - currentRef - ); - break; - case 3: - var _updateQueue = current$$1.updateQueue; - if (null !== _updateQueue) { - root = null; - if (null !== current$$1.child) - switch (current$$1.child.tag) { - case 5: - root = current$$1.child.stateNode; - break; - case 1: - root = current$$1.child.stateNode; - } - commitUpdateQueue(current$$1, _updateQueue, root, currentRef); - } - break; - case 5: - break; - case 6: - break; - case 4: - break; - case 12: - break; - case 13: - break; - case 19: - case 17: - case 20: - case 21: - 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." - ); - } - } + effectTag$jscomp$0 & 36 && + commitLifeCycles( + effectTag, + nextEffect.alternate, + nextEffect, + current$$1 + ); if (effectTag$jscomp$0 & 128) { - current$$1 = void 0; + currentRef = void 0; var ref = nextEffect.ref; if (null !== ref) { - var instance$jscomp$0 = nextEffect.stateNode; + var instance = nextEffect.stateNode; switch (nextEffect.tag) { case 5: - current$$1 = instance$jscomp$0; + currentRef = instance; break; default: - current$$1 = instance$jscomp$0; + currentRef = instance; } "function" === typeof ref - ? ref(current$$1) - : (ref.current = current$$1); + ? ref(currentRef) + : (ref.current = currentRef); } } nextEffect = nextEffect.nextEffect; @@ -6764,6 +6689,7 @@ function flushPassiveEffectsImpl() { case 0: case 11: case 15: + case 22: commitHookEffectList(128, 0, finishedWork), commitHookEffectList(0, 64, finishedWork); } @@ -6973,6 +6899,7 @@ beginWork$$1 = function(current$$1, workInProgress, renderExpirationTime) { null !== renderState.state && void 0 !== renderState.state ? renderState.state : null; + initializeUpdateQueue(workInProgress); var getDerivedStateFromProps = updateExpirationTime.getDerivedStateFromProps; "function" === typeof getDerivedStateFromProps && @@ -7010,62 +6937,63 @@ beginWork$$1 = function(current$$1, workInProgress, renderExpirationTime) { (workInProgress = workInProgress.child); return workInProgress; case 16: - renderState = workInProgress.elementType; - null !== current$$1 && - ((current$$1.alternate = null), - (workInProgress.alternate = null), - (workInProgress.effectTag |= 2)); - current$$1 = workInProgress.pendingProps; - initializeLazyComponentType(renderState); - if (1 !== renderState._status) throw renderState._result; - renderState = renderState._result; - workInProgress.type = renderState; - hasContext = workInProgress.tag = resolveLazyComponentTag(renderState); - current$$1 = resolveDefaultProps(renderState, current$$1); - switch (hasContext) { - case 0: - workInProgress = updateFunctionComponent( - null, - workInProgress, - renderState, - current$$1, - renderExpirationTime - ); - break; - case 1: - workInProgress = updateClassComponent( - null, - workInProgress, - renderState, - current$$1, - renderExpirationTime - ); - break; - case 11: - workInProgress = updateForwardRef( - null, - workInProgress, - renderState, - current$$1, - renderExpirationTime - ); - break; - case 14: - workInProgress = updateMemoComponent( - null, - workInProgress, - renderState, - resolveDefaultProps(renderState.type, current$$1), - updateExpirationTime, - renderExpirationTime - ); - break; - default: - throw Error( - "Element type is invalid. Received a promise that resolves to: " + - renderState + - ". Lazy element type must resolve to a class or function." - ); + a: { + renderState = workInProgress.elementType; + null !== current$$1 && + ((current$$1.alternate = null), + (workInProgress.alternate = null), + (workInProgress.effectTag |= 2)); + current$$1 = workInProgress.pendingProps; + initializeLazyComponentType(renderState); + if (1 !== renderState._status) throw renderState._result; + renderState = renderState._result; + workInProgress.type = renderState; + hasContext = workInProgress.tag = resolveLazyComponentTag(renderState); + current$$1 = resolveDefaultProps(renderState, current$$1); + switch (hasContext) { + case 0: + workInProgress = updateFunctionComponent( + null, + workInProgress, + renderState, + current$$1, + renderExpirationTime + ); + break a; + case 1: + workInProgress = updateClassComponent( + null, + workInProgress, + renderState, + current$$1, + renderExpirationTime + ); + break a; + case 11: + workInProgress = updateForwardRef( + null, + workInProgress, + renderState, + current$$1, + renderExpirationTime + ); + break a; + case 14: + workInProgress = updateMemoComponent( + null, + workInProgress, + renderState, + resolveDefaultProps(renderState.type, current$$1), + updateExpirationTime, + renderExpirationTime + ); + break a; + } + throw Error( + "Element type is invalid. Received a promise that resolves to: " + + renderState + + ". Lazy element type must resolve to a class or function." + ); } return workInProgress; case 0: @@ -7103,16 +7031,17 @@ beginWork$$1 = function(current$$1, workInProgress, renderExpirationTime) { case 3: pushHostRootContext(workInProgress); updateExpirationTime = workInProgress.updateQueue; - if (null === updateExpirationTime) + if (null === current$$1 || null === updateExpirationTime) throw Error( "If the root does not have an updateQueue, we should have already bailed out. This error is likely caused by a bug in React. Please file an issue." ); + updateExpirationTime = workInProgress.pendingProps; renderState = workInProgress.memoizedState; renderState = null !== renderState ? renderState.element : null; + cloneUpdateQueue(current$$1, workInProgress); processUpdateQueue( workInProgress, updateExpirationTime, - workInProgress.pendingProps, null, renderExpirationTime ); @@ -7596,6 +7525,9 @@ function createFiberFromTypeAndProps( fiberTag = 16; owner = null; break a; + case REACT_CHUNK_TYPE: + fiberTag = 22; + break a; } throw Error( "Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: " + @@ -7916,11 +7848,17 @@ var roots = new Map(), findNodeHandle: findNodeHandle, dispatchCommand: function(handle, command, args) { null != handle._nativeTag && - ReactNativePrivateInterface.UIManager.dispatchViewManagerCommand( - handle._nativeTag, - command, - args - ); + (handle._internalInstanceHandle + ? nativeFabricUIManager.dispatchCommand( + handle._internalInstanceHandle.stateNode.node, + command, + args + ) + : ReactNativePrivateInterface.UIManager.dispatchViewManagerCommand( + handle._nativeTag, + command, + args + )); }, render: function(element, containerTag, callback) { var root = roots.get(containerTag); @@ -7929,6 +7867,7 @@ var roots = new Map(), var uninitializedFiber = createFiber(3, null, null, 0); root.current = uninitializedFiber; uninitializedFiber.stateNode = root; + initializeUpdateQueue(uninitializedFiber); roots.set(containerTag, root); } updateContainer(element, root, null, callback); @@ -8088,7 +8027,7 @@ var roots = new Map(), throw Error("getInspectorDataForViewTag() is not available in production"); }, bundleType: 0, - version: "16.11.0", + version: "16.12.0-experimental-19f6fe170", rendererPackageName: "react-native-renderer" }); var ReactNativeRenderer$2 = { default: ReactNativeRenderer }, diff --git a/Libraries/Renderer/implementations/ReactNativeRenderer-prod.js b/Libraries/Renderer/implementations/ReactNativeRenderer-prod.js index 4cc776abd951fd..df962ae5daff6e 100644 --- a/Libraries/Renderer/implementations/ReactNativeRenderer-prod.js +++ b/Libraries/Renderer/implementations/ReactNativeRenderer-prod.js @@ -503,53 +503,27 @@ function recordTouchStart(touch) { } function recordTouchMove(touch) { var touchRecord = touchBank[getTouchIdentifier(touch)]; - touchRecord - ? ((touchRecord.touchActive = !0), - (touchRecord.previousPageX = touchRecord.currentPageX), - (touchRecord.previousPageY = touchRecord.currentPageY), - (touchRecord.previousTimeStamp = touchRecord.currentTimeStamp), - (touchRecord.currentPageX = touch.pageX), - (touchRecord.currentPageY = touch.pageY), - (touchRecord.currentTimeStamp = timestampForTouch(touch)), - (touchHistory.mostRecentTimeStamp = timestampForTouch(touch))) - : console.warn( - "Cannot record touch move without a touch start.\nTouch Move: %s\n", - "Touch Bank: %s", - printTouch(touch), - printTouchBank() - ); + touchRecord && + ((touchRecord.touchActive = !0), + (touchRecord.previousPageX = touchRecord.currentPageX), + (touchRecord.previousPageY = touchRecord.currentPageY), + (touchRecord.previousTimeStamp = touchRecord.currentTimeStamp), + (touchRecord.currentPageX = touch.pageX), + (touchRecord.currentPageY = touch.pageY), + (touchRecord.currentTimeStamp = timestampForTouch(touch)), + (touchHistory.mostRecentTimeStamp = timestampForTouch(touch))); } function recordTouchEnd(touch) { var touchRecord = touchBank[getTouchIdentifier(touch)]; - touchRecord - ? ((touchRecord.touchActive = !1), - (touchRecord.previousPageX = touchRecord.currentPageX), - (touchRecord.previousPageY = touchRecord.currentPageY), - (touchRecord.previousTimeStamp = touchRecord.currentTimeStamp), - (touchRecord.currentPageX = touch.pageX), - (touchRecord.currentPageY = touch.pageY), - (touchRecord.currentTimeStamp = timestampForTouch(touch)), - (touchHistory.mostRecentTimeStamp = timestampForTouch(touch))) - : console.warn( - "Cannot record touch end without a touch start.\nTouch End: %s\n", - "Touch Bank: %s", - printTouch(touch), - printTouchBank() - ); -} -function printTouch(touch) { - return JSON.stringify({ - identifier: touch.identifier, - pageX: touch.pageX, - pageY: touch.pageY, - timestamp: timestampForTouch(touch) - }); -} -function printTouchBank() { - var printed = JSON.stringify(touchBank.slice(0, 20)); - 20 < touchBank.length && - (printed += " (original size: " + touchBank.length + ")"); - return printed; + touchRecord && + ((touchRecord.touchActive = !1), + (touchRecord.previousPageX = touchRecord.currentPageX), + (touchRecord.previousPageY = touchRecord.currentPageY), + (touchRecord.previousTimeStamp = touchRecord.currentTimeStamp), + (touchRecord.currentPageX = touch.pageX), + (touchRecord.currentPageY = touch.pageY), + (touchRecord.currentTimeStamp = timestampForTouch(touch)), + (touchHistory.mostRecentTimeStamp = timestampForTouch(touch))); } var ResponderTouchHistoryStore = { recordTouchTrack: function(topLevelType, nativeEvent) { @@ -682,13 +656,7 @@ var eventTypes = { "topTouchCancel" === topLevelType ) if (0 <= trackedTouchCount) --trackedTouchCount; - else - return ( - console.warn( - "Ended a touch event which was not counted in `trackedTouchCount`." - ), - null - ); + else return null; ResponderTouchHistoryStore.recordTouchTrack(topLevelType, nativeEvent); if ( targetInst && @@ -1149,7 +1117,8 @@ var hasSymbol = "function" === typeof Symbol && Symbol.for, ? Symbol.for("react.suspense_list") : 60120, REACT_MEMO_TYPE = hasSymbol ? Symbol.for("react.memo") : 60115, - REACT_LAZY_TYPE = hasSymbol ? Symbol.for("react.lazy") : 60116; + REACT_LAZY_TYPE = hasSymbol ? Symbol.for("react.lazy") : 60116, + REACT_CHUNK_TYPE = hasSymbol ? Symbol.for("react.chunk") : 60121; hasSymbol && Symbol.for("react.fundamental"); hasSymbol && Symbol.for("react.responder"); hasSymbol && Symbol.for("react.scope"); @@ -1214,6 +1183,8 @@ function getComponentName(type) { ); case REACT_MEMO_TYPE: return getComponentName(type.type); + case REACT_CHUNK_TYPE: + return getComponentName(type.render); case REACT_LAZY_TYPE: if ((type = 1 === type._status ? type._result : null)) return getComponentName(type); @@ -2007,237 +1978,195 @@ function readContext(context, observedBits) { return context._currentValue; } var hasForceUpdate = !1; -function createUpdateQueue(baseState) { - return { - baseState: baseState, - firstUpdate: null, - lastUpdate: null, - firstCapturedUpdate: null, - lastCapturedUpdate: null, - firstEffect: null, - lastEffect: null, - firstCapturedEffect: null, - lastCapturedEffect: null +function initializeUpdateQueue(fiber) { + fiber.updateQueue = { + baseState: fiber.memoizedState, + baseQueue: null, + shared: { pending: null }, + effects: null }; } -function cloneUpdateQueue(currentQueue) { - return { - baseState: currentQueue.baseState, - firstUpdate: currentQueue.firstUpdate, - lastUpdate: currentQueue.lastUpdate, - firstCapturedUpdate: null, - lastCapturedUpdate: null, - firstEffect: null, - lastEffect: null, - firstCapturedEffect: null, - lastCapturedEffect: null - }; +function cloneUpdateQueue(current, workInProgress) { + current = current.updateQueue; + workInProgress.updateQueue === current && + (workInProgress.updateQueue = { + baseState: current.baseState, + baseQueue: current.baseQueue, + shared: current.shared, + effects: current.effects + }); } function createUpdate(expirationTime, suspenseConfig) { - return { + expirationTime = { expirationTime: expirationTime, suspenseConfig: suspenseConfig, tag: 0, payload: null, callback: null, - next: null, - nextEffect: null + next: null }; -} -function appendUpdateToQueue(queue, update) { - null === queue.lastUpdate - ? (queue.firstUpdate = queue.lastUpdate = update) - : ((queue.lastUpdate.next = update), (queue.lastUpdate = update)); + return (expirationTime.next = expirationTime); } function enqueueUpdate(fiber, update) { - var alternate = fiber.alternate; - if (null === alternate) { - var queue1 = fiber.updateQueue; - var queue2 = null; - null === queue1 && - (queue1 = fiber.updateQueue = createUpdateQueue(fiber.memoizedState)); - } else - (queue1 = fiber.updateQueue), - (queue2 = alternate.updateQueue), - null === queue1 - ? null === queue2 - ? ((queue1 = fiber.updateQueue = createUpdateQueue( - fiber.memoizedState - )), - (queue2 = alternate.updateQueue = createUpdateQueue( - alternate.memoizedState - ))) - : (queue1 = fiber.updateQueue = cloneUpdateQueue(queue2)) - : null === queue2 && - (queue2 = alternate.updateQueue = cloneUpdateQueue(queue1)); - null === queue2 || queue1 === queue2 - ? appendUpdateToQueue(queue1, update) - : null === queue1.lastUpdate || null === queue2.lastUpdate - ? (appendUpdateToQueue(queue1, update), - appendUpdateToQueue(queue2, update)) - : (appendUpdateToQueue(queue1, update), (queue2.lastUpdate = update)); + fiber = fiber.updateQueue; + if (null !== fiber) { + fiber = fiber.shared; + var pending = fiber.pending; + null === pending + ? (update.next = update) + : ((update.next = pending.next), (pending.next = update)); + fiber.pending = update; + } } function enqueueCapturedUpdate(workInProgress, update) { - var workInProgressQueue = workInProgress.updateQueue; - workInProgressQueue = - null === workInProgressQueue - ? (workInProgress.updateQueue = createUpdateQueue( - workInProgress.memoizedState - )) - : ensureWorkInProgressQueueIsAClone(workInProgress, workInProgressQueue); - null === workInProgressQueue.lastCapturedUpdate - ? (workInProgressQueue.firstCapturedUpdate = workInProgressQueue.lastCapturedUpdate = update) - : ((workInProgressQueue.lastCapturedUpdate.next = update), - (workInProgressQueue.lastCapturedUpdate = update)); -} -function ensureWorkInProgressQueueIsAClone(workInProgress, queue) { var current = workInProgress.alternate; - null !== current && - queue === current.updateQueue && - (queue = workInProgress.updateQueue = cloneUpdateQueue(queue)); - return queue; -} -function getStateFromUpdate( - workInProgress, - queue, - update, - prevState, - nextProps, - instance -) { - switch (update.tag) { - case 1: - return ( - (workInProgress = update.payload), - "function" === typeof workInProgress - ? workInProgress.call(instance, prevState, nextProps) - : workInProgress - ); - case 3: - workInProgress.effectTag = (workInProgress.effectTag & -4097) | 64; - case 0: - workInProgress = update.payload; - nextProps = - "function" === typeof workInProgress - ? workInProgress.call(instance, prevState, nextProps) - : workInProgress; - if (null === nextProps || void 0 === nextProps) break; - return Object.assign({}, prevState, nextProps); - case 2: - hasForceUpdate = !0; - } - return prevState; + null !== current && cloneUpdateQueue(current, workInProgress); + workInProgress = workInProgress.updateQueue; + current = workInProgress.baseQueue; + null === current + ? ((workInProgress.baseQueue = update.next = update), + (update.next = update)) + : ((update.next = current.next), (current.next = update)); } function processUpdateQueue( - workInProgress, - queue, + workInProgress$jscomp$0, props, instance, renderExpirationTime ) { + var queue = workInProgress$jscomp$0.updateQueue; hasForceUpdate = !1; - queue = ensureWorkInProgressQueueIsAClone(workInProgress, queue); - for ( - var newBaseState = queue.baseState, - newFirstUpdate = null, - newExpirationTime = 0, - update = queue.firstUpdate, - resultState = newBaseState; - null !== update; - - ) { - var updateExpirationTime = update.expirationTime; - updateExpirationTime < renderExpirationTime - ? (null === newFirstUpdate && - ((newFirstUpdate = update), (newBaseState = resultState)), - newExpirationTime < updateExpirationTime && - (newExpirationTime = updateExpirationTime)) - : (markRenderEventTimeAndConfig( - updateExpirationTime, - update.suspenseConfig - ), - (resultState = getStateFromUpdate( - workInProgress, - queue, - update, - resultState, - props, - instance - )), - null !== update.callback && - ((workInProgress.effectTag |= 32), - (update.nextEffect = null), - null === queue.lastEffect - ? (queue.firstEffect = queue.lastEffect = update) - : ((queue.lastEffect.nextEffect = update), - (queue.lastEffect = update)))); - update = update.next; + var baseQueue = queue.baseQueue, + pendingQueue = queue.shared.pending; + if (null !== pendingQueue) { + if (null !== baseQueue) { + var baseFirst = baseQueue.next; + baseQueue.next = pendingQueue.next; + pendingQueue.next = baseFirst; + } + baseQueue = pendingQueue; + queue.shared.pending = null; + baseFirst = workInProgress$jscomp$0.alternate; + null !== baseFirst && + ((baseFirst = baseFirst.updateQueue), + null !== baseFirst && (baseFirst.baseQueue = pendingQueue)); } - updateExpirationTime = null; - for (update = queue.firstCapturedUpdate; null !== update; ) { - var _updateExpirationTime = update.expirationTime; - _updateExpirationTime < renderExpirationTime - ? (null === updateExpirationTime && - ((updateExpirationTime = update), - null === newFirstUpdate && (newBaseState = resultState)), - newExpirationTime < _updateExpirationTime && - (newExpirationTime = _updateExpirationTime)) - : ((resultState = getStateFromUpdate( - workInProgress, - queue, - update, - resultState, - props, - instance - )), - null !== update.callback && - ((workInProgress.effectTag |= 32), - (update.nextEffect = null), - null === queue.lastCapturedEffect - ? (queue.firstCapturedEffect = queue.lastCapturedEffect = update) - : ((queue.lastCapturedEffect.nextEffect = update), - (queue.lastCapturedEffect = update)))); - update = update.next; + if (null !== baseQueue) { + baseFirst = baseQueue.next; + var newState = queue.baseState, + newExpirationTime = 0, + newBaseState = null, + newBaseQueueFirst = null, + newBaseQueueLast = null; + if (null !== baseFirst) { + var update = baseFirst; + do { + pendingQueue = update.expirationTime; + if (pendingQueue < renderExpirationTime) { + var clone = { + expirationTime: update.expirationTime, + suspenseConfig: update.suspenseConfig, + tag: update.tag, + payload: update.payload, + callback: update.callback, + next: null + }; + null === newBaseQueueLast + ? ((newBaseQueueFirst = newBaseQueueLast = clone), + (newBaseState = newState)) + : (newBaseQueueLast = newBaseQueueLast.next = clone); + pendingQueue > newExpirationTime && + (newExpirationTime = pendingQueue); + } else { + null !== newBaseQueueLast && + (newBaseQueueLast = newBaseQueueLast.next = { + expirationTime: 1073741823, + suspenseConfig: update.suspenseConfig, + tag: update.tag, + payload: update.payload, + callback: update.callback, + next: null + }); + markRenderEventTimeAndConfig(pendingQueue, update.suspenseConfig); + a: { + var workInProgress = workInProgress$jscomp$0, + update$jscomp$0 = update; + pendingQueue = props; + clone = instance; + switch (update$jscomp$0.tag) { + case 1: + workInProgress = update$jscomp$0.payload; + if ("function" === typeof workInProgress) { + newState = workInProgress.call(clone, newState, pendingQueue); + break a; + } + newState = workInProgress; + break a; + case 3: + workInProgress.effectTag = + (workInProgress.effectTag & -4097) | 64; + case 0: + workInProgress = update$jscomp$0.payload; + pendingQueue = + "function" === typeof workInProgress + ? workInProgress.call(clone, newState, pendingQueue) + : workInProgress; + if (null === pendingQueue || void 0 === pendingQueue) break a; + newState = Object.assign({}, newState, pendingQueue); + break a; + case 2: + hasForceUpdate = !0; + } + } + null !== update.callback && + ((workInProgress$jscomp$0.effectTag |= 32), + (pendingQueue = queue.effects), + null === pendingQueue + ? (queue.effects = [update]) + : pendingQueue.push(update)); + } + update = update.next; + if (null === update || update === baseFirst) + if (((pendingQueue = queue.shared.pending), null === pendingQueue)) + break; + else + (update = baseQueue.next = pendingQueue.next), + (pendingQueue.next = baseFirst), + (queue.baseQueue = baseQueue = pendingQueue), + (queue.shared.pending = null); + } while (1); + } + null === newBaseQueueLast + ? (newBaseState = newState) + : (newBaseQueueLast.next = newBaseQueueFirst); + queue.baseState = newBaseState; + queue.baseQueue = newBaseQueueLast; + markUnprocessedUpdateTime(newExpirationTime); + workInProgress$jscomp$0.expirationTime = newExpirationTime; + workInProgress$jscomp$0.memoizedState = newState; } - null === newFirstUpdate && (queue.lastUpdate = null); - null === updateExpirationTime - ? (queue.lastCapturedUpdate = null) - : (workInProgress.effectTag |= 32); - null === newFirstUpdate && - null === updateExpirationTime && - (newBaseState = resultState); - queue.baseState = newBaseState; - queue.firstUpdate = newFirstUpdate; - queue.firstCapturedUpdate = updateExpirationTime; - markUnprocessedUpdateTime(newExpirationTime); - workInProgress.expirationTime = newExpirationTime; - workInProgress.memoizedState = resultState; } function commitUpdateQueue(finishedWork, finishedQueue, instance) { - null !== finishedQueue.firstCapturedUpdate && - (null !== finishedQueue.lastUpdate && - ((finishedQueue.lastUpdate.next = finishedQueue.firstCapturedUpdate), - (finishedQueue.lastUpdate = finishedQueue.lastCapturedUpdate)), - (finishedQueue.firstCapturedUpdate = finishedQueue.lastCapturedUpdate = null)); - commitUpdateEffects(finishedQueue.firstEffect, instance); - finishedQueue.firstEffect = finishedQueue.lastEffect = null; - commitUpdateEffects(finishedQueue.firstCapturedEffect, instance); - finishedQueue.firstCapturedEffect = finishedQueue.lastCapturedEffect = null; -} -function commitUpdateEffects(effect, instance) { - for (; null !== effect; ) { - var callback = effect.callback; - if (null !== callback) { - effect.callback = null; - if ("function" !== typeof callback) - throw Error( - "Invalid argument passed as callback. Expected a function. Instead received: " + - callback - ); - callback.call(instance); + finishedWork = finishedQueue.effects; + finishedQueue.effects = null; + if (null !== finishedWork) + for ( + finishedQueue = 0; + finishedQueue < finishedWork.length; + finishedQueue++ + ) { + var effect = finishedWork[finishedQueue], + callback = effect.callback; + if (null !== callback) { + effect.callback = null; + if ("function" !== typeof callback) + throw Error( + "Invalid argument passed as callback. Expected a function. Instead received: " + + callback + ); + callback.call(instance); + } } - effect = effect.nextEffect; - } } var ReactCurrentBatchConfig = ReactSharedInternals.ReactCurrentBatchConfig, emptyRefsObject = new React.Component().refs; @@ -2254,10 +2183,8 @@ function applyDerivedStateFromProps( ? ctor : Object.assign({}, ctor, getDerivedStateFromProps); workInProgress.memoizedState = getDerivedStateFromProps; - nextProps = workInProgress.updateQueue; - null !== nextProps && - 0 === workInProgress.expirationTime && - (nextProps.baseState = getDerivedStateFromProps); + 0 === workInProgress.expirationTime && + (workInProgress.updateQueue.baseState = getDerivedStateFromProps); } var classComponentUpdater = { isMounted: function(component) { @@ -2372,6 +2299,7 @@ function mountClassInstance( instance.props = newProps; instance.state = workInProgress.memoizedState; instance.refs = emptyRefsObject; + initializeUpdateQueue(workInProgress); var contextType = ctor.contextType; "object" === typeof contextType && null !== contextType ? (instance.context = readContext(contextType)) @@ -2379,16 +2307,8 @@ function mountClassInstance( ? previousContext : contextStackCursor.current), (instance.context = getMaskedContext(workInProgress, contextType))); - contextType = workInProgress.updateQueue; - null !== contextType && - (processUpdateQueue( - workInProgress, - contextType, - newProps, - instance, - renderExpirationTime - ), - (instance.state = workInProgress.memoizedState)); + processUpdateQueue(workInProgress, newProps, instance, renderExpirationTime); + instance.state = workInProgress.memoizedState; contextType = ctor.getDerivedStateFromProps; "function" === typeof contextType && (applyDerivedStateFromProps(workInProgress, ctor, contextType, newProps), @@ -2404,16 +2324,13 @@ function mountClassInstance( instance.UNSAFE_componentWillMount(), ctor !== instance.state && classComponentUpdater.enqueueReplaceState(instance, instance.state, null), - (contextType = workInProgress.updateQueue), - null !== contextType && - (processUpdateQueue( - workInProgress, - contextType, - newProps, - instance, - renderExpirationTime - ), - (instance.state = workInProgress.memoizedState))); + processUpdateQueue( + workInProgress, + newProps, + instance, + renderExpirationTime + ), + (instance.state = workInProgress.memoizedState)); "function" === typeof instance.componentDidMount && (workInProgress.effectTag |= 4); } @@ -2975,39 +2892,50 @@ function ChildReconciler(shouldTrackSideEffects) { null !== isUnkeyedTopLevelFragment; ) { - if (isUnkeyedTopLevelFragment.key === isObject) - if ( - 7 === isUnkeyedTopLevelFragment.tag - ? newChild.type === REACT_FRAGMENT_TYPE - : isUnkeyedTopLevelFragment.elementType === newChild.type - ) { - deleteRemainingChildren( - returnFiber, - isUnkeyedTopLevelFragment.sibling - ); - currentFirstChild = useFiber( - isUnkeyedTopLevelFragment, - newChild.type === REACT_FRAGMENT_TYPE - ? newChild.props.children - : newChild.props, - expirationTime - ); - currentFirstChild.ref = coerceRef( - returnFiber, - isUnkeyedTopLevelFragment, - newChild - ); - currentFirstChild.return = returnFiber; - returnFiber = currentFirstChild; - break a; - } else { - deleteRemainingChildren( - returnFiber, - isUnkeyedTopLevelFragment - ); - break; + if (isUnkeyedTopLevelFragment.key === isObject) { + switch (isUnkeyedTopLevelFragment.tag) { + case 7: + if (newChild.type === REACT_FRAGMENT_TYPE) { + deleteRemainingChildren( + returnFiber, + isUnkeyedTopLevelFragment.sibling + ); + currentFirstChild = useFiber( + isUnkeyedTopLevelFragment, + newChild.props.children, + expirationTime + ); + currentFirstChild.return = returnFiber; + returnFiber = currentFirstChild; + break a; + } + break; + default: + if ( + isUnkeyedTopLevelFragment.elementType === newChild.type + ) { + deleteRemainingChildren( + returnFiber, + isUnkeyedTopLevelFragment.sibling + ); + currentFirstChild = useFiber( + isUnkeyedTopLevelFragment, + newChild.props, + expirationTime + ); + currentFirstChild.ref = coerceRef( + returnFiber, + isUnkeyedTopLevelFragment, + newChild + ); + currentFirstChild.return = returnFiber; + returnFiber = currentFirstChild; + break a; + } } - else deleteChild(returnFiber, isUnkeyedTopLevelFragment); + deleteRemainingChildren(returnFiber, isUnkeyedTopLevelFragment); + break; + } else deleteChild(returnFiber, isUnkeyedTopLevelFragment); isUnkeyedTopLevelFragment = isUnkeyedTopLevelFragment.sibling; } newChild.type === REACT_FRAGMENT_TYPE @@ -3205,7 +3133,7 @@ function findFirstSuspended(row) { } return null; } -function createResponderListener(responder, props) { +function createDeprecatedResponderListener(responder, props) { return { responder: responder, props: props }; } var ReactCurrentDispatcher$1 = ReactSharedInternals.ReactCurrentDispatcher, @@ -3213,13 +3141,7 @@ var ReactCurrentDispatcher$1 = ReactSharedInternals.ReactCurrentDispatcher, renderExpirationTime$1 = 0, currentlyRenderingFiber$1 = null, currentHook = null, - nextCurrentHook = null, - firstWorkInProgressHook = null, workInProgressHook = null, - nextWorkInProgressHook = null, - remainingExpirationTime = 0, - componentUpdateQueue = null, - sideEffectTag = 0, didScheduleRenderPhaseUpdate = !1, renderPhaseUpdates = null, numberOfReRenders = 0; @@ -3239,53 +3161,45 @@ function renderWithHooks( workInProgress, Component, props, - refOrContext, + secondArg, nextRenderExpirationTime ) { renderExpirationTime$1 = nextRenderExpirationTime; currentlyRenderingFiber$1 = workInProgress; - nextCurrentHook = null !== current ? current.memoizedState : null; + workInProgress.memoizedState = null; + workInProgress.updateQueue = null; + workInProgress.expirationTime = 0; ReactCurrentDispatcher$1.current = - null === nextCurrentHook ? HooksDispatcherOnMount : HooksDispatcherOnUpdate; - workInProgress = Component(props, refOrContext); + null === current || null === current.memoizedState + ? HooksDispatcherOnMount + : HooksDispatcherOnUpdate; + current = Component(props, secondArg); if (didScheduleRenderPhaseUpdate) { do (didScheduleRenderPhaseUpdate = !1), (numberOfReRenders += 1), - (nextCurrentHook = null !== current ? current.memoizedState : null), - (nextWorkInProgressHook = firstWorkInProgressHook), - (componentUpdateQueue = workInProgressHook = currentHook = null), + (workInProgressHook = currentHook = null), + (workInProgress.updateQueue = null), (ReactCurrentDispatcher$1.current = HooksDispatcherOnUpdate), - (workInProgress = Component(props, refOrContext)); + (current = Component(props, secondArg)); while (didScheduleRenderPhaseUpdate); renderPhaseUpdates = null; numberOfReRenders = 0; } ReactCurrentDispatcher$1.current = ContextOnlyDispatcher; - current = currentlyRenderingFiber$1; - current.memoizedState = firstWorkInProgressHook; - current.expirationTime = remainingExpirationTime; - current.updateQueue = componentUpdateQueue; - current.effectTag |= sideEffectTag; - current = null !== currentHook && null !== currentHook.next; + workInProgress = null !== currentHook && null !== currentHook.next; renderExpirationTime$1 = 0; - nextWorkInProgressHook = workInProgressHook = firstWorkInProgressHook = nextCurrentHook = currentHook = currentlyRenderingFiber$1 = null; - remainingExpirationTime = 0; - componentUpdateQueue = null; - sideEffectTag = 0; - if (current) + workInProgressHook = currentHook = currentlyRenderingFiber$1 = null; + if (workInProgress) throw Error( "Rendered fewer hooks than expected. This may be caused by an accidental early return statement." ); - return workInProgress; + return current; } function resetHooks() { ReactCurrentDispatcher$1.current = ContextOnlyDispatcher; renderExpirationTime$1 = 0; - nextWorkInProgressHook = workInProgressHook = firstWorkInProgressHook = nextCurrentHook = currentHook = currentlyRenderingFiber$1 = null; - remainingExpirationTime = 0; - componentUpdateQueue = null; - sideEffectTag = 0; + workInProgressHook = currentHook = currentlyRenderingFiber$1 = null; didScheduleRenderPhaseUpdate = !1; renderPhaseUpdates = null; numberOfReRenders = 0; @@ -3294,37 +3208,42 @@ function mountWorkInProgressHook() { var hook = { memoizedState: null, baseState: null, + baseQueue: null, queue: null, - baseUpdate: null, next: null }; null === workInProgressHook - ? (firstWorkInProgressHook = workInProgressHook = hook) + ? (currentlyRenderingFiber$1.memoizedState = workInProgressHook = hook) : (workInProgressHook = workInProgressHook.next = hook); return workInProgressHook; } function updateWorkInProgressHook() { + if (null === currentHook) { + var nextCurrentHook = currentlyRenderingFiber$1.alternate; + nextCurrentHook = + null !== nextCurrentHook ? nextCurrentHook.memoizedState : null; + } else nextCurrentHook = currentHook.next; + var nextWorkInProgressHook = + null === workInProgressHook + ? currentlyRenderingFiber$1.memoizedState + : workInProgressHook.next; if (null !== nextWorkInProgressHook) (workInProgressHook = nextWorkInProgressHook), - (nextWorkInProgressHook = workInProgressHook.next), - (currentHook = nextCurrentHook), - (nextCurrentHook = null !== currentHook ? currentHook.next : null); + (currentHook = nextCurrentHook); else { if (null === nextCurrentHook) throw Error("Rendered more hooks than during the previous render."); currentHook = nextCurrentHook; - var newHook = { + nextCurrentHook = { memoizedState: currentHook.memoizedState, baseState: currentHook.baseState, + baseQueue: currentHook.baseQueue, queue: currentHook.queue, - baseUpdate: currentHook.baseUpdate, next: null }; - workInProgressHook = - null === workInProgressHook - ? (firstWorkInProgressHook = newHook) - : (workInProgressHook.next = newHook); - nextCurrentHook = currentHook.next; + null === workInProgressHook + ? (currentlyRenderingFiber$1.memoizedState = workInProgressHook = nextCurrentHook) + : (workInProgressHook = workInProgressHook.next = nextCurrentHook); } return workInProgressHook; } @@ -3352,51 +3271,75 @@ function updateReducer(reducer) { while (null !== firstRenderPhaseUpdate); is$1(newState, hook.memoizedState) || (didReceiveUpdate = !0); hook.memoizedState = newState; - hook.baseUpdate === queue.last && (hook.baseState = newState); + null === hook.baseQueue && (hook.baseState = newState); queue.lastRenderedState = newState; return [newState, _dispatch]; } } return [hook.memoizedState, _dispatch]; } - _dispatch = queue.last; - var baseUpdate = hook.baseUpdate; - newState = hook.baseState; - null !== baseUpdate - ? (null !== _dispatch && (_dispatch.next = null), - (_dispatch = baseUpdate.next)) - : (_dispatch = null !== _dispatch ? _dispatch.next : null); + newState = currentHook; + _dispatch = newState.baseQueue; + firstRenderPhaseUpdate = queue.pending; + if (null !== firstRenderPhaseUpdate) { + if (null !== _dispatch) { + var baseFirst = _dispatch.next; + _dispatch.next = firstRenderPhaseUpdate.next; + firstRenderPhaseUpdate.next = baseFirst; + } + newState.baseQueue = _dispatch = firstRenderPhaseUpdate; + queue.pending = null; + } if (null !== _dispatch) { - var newBaseUpdate = (firstRenderPhaseUpdate = null), - _update = _dispatch, - didSkip = !1; + _dispatch = _dispatch.next; + newState = newState.baseState; + var newBaseQueueLast = (baseFirst = firstRenderPhaseUpdate = null), + _update = _dispatch; do { var updateExpirationTime = _update.expirationTime; - updateExpirationTime < renderExpirationTime$1 - ? (didSkip || - ((didSkip = !0), - (newBaseUpdate = baseUpdate), - (firstRenderPhaseUpdate = newState)), - updateExpirationTime > remainingExpirationTime && - ((remainingExpirationTime = updateExpirationTime), - markUnprocessedUpdateTime(remainingExpirationTime))) - : (markRenderEventTimeAndConfig( + if (updateExpirationTime < renderExpirationTime$1) { + var clone = { + expirationTime: _update.expirationTime, + suspenseConfig: _update.suspenseConfig, + action: _update.action, + eagerReducer: _update.eagerReducer, + eagerState: _update.eagerState, + next: null + }; + null === newBaseQueueLast + ? ((baseFirst = newBaseQueueLast = clone), + (firstRenderPhaseUpdate = newState)) + : (newBaseQueueLast = newBaseQueueLast.next = clone); + updateExpirationTime > currentlyRenderingFiber$1.expirationTime && + ((currentlyRenderingFiber$1.expirationTime = updateExpirationTime), + markUnprocessedUpdateTime(updateExpirationTime)); + } else + null !== newBaseQueueLast && + (newBaseQueueLast = newBaseQueueLast.next = { + expirationTime: 1073741823, + suspenseConfig: _update.suspenseConfig, + action: _update.action, + eagerReducer: _update.eagerReducer, + eagerState: _update.eagerState, + next: null + }), + markRenderEventTimeAndConfig( updateExpirationTime, _update.suspenseConfig ), (newState = _update.eagerReducer === reducer ? _update.eagerState - : reducer(newState, _update.action))); - baseUpdate = _update; + : reducer(newState, _update.action)); _update = _update.next; } while (null !== _update && _update !== _dispatch); - didSkip || - ((newBaseUpdate = baseUpdate), (firstRenderPhaseUpdate = newState)); + null === newBaseQueueLast + ? (firstRenderPhaseUpdate = newState) + : (newBaseQueueLast.next = baseFirst); is$1(newState, hook.memoizedState) || (didReceiveUpdate = !0); hook.memoizedState = newState; - hook.baseUpdate = newBaseUpdate; hook.baseState = firstRenderPhaseUpdate; + hook.baseQueue = newBaseQueueLast; queue.lastRenderedState = newState; } return [hook.memoizedState, queue.dispatch]; @@ -3406,7 +3349,7 @@ function mountState(initialState) { "function" === typeof initialState && (initialState = initialState()); hook.memoizedState = hook.baseState = initialState; initialState = hook.queue = { - last: null, + pending: null, dispatch: null, lastRenderedReducer: basicStateReducer, lastRenderedState: initialState @@ -3423,21 +3366,23 @@ function updateState(initialState) { } function pushEffect(tag, create, destroy, deps) { tag = { tag: tag, create: create, destroy: destroy, deps: deps, next: null }; - null === componentUpdateQueue - ? ((componentUpdateQueue = { lastEffect: null }), - (componentUpdateQueue.lastEffect = tag.next = tag)) - : ((create = componentUpdateQueue.lastEffect), - null === create - ? (componentUpdateQueue.lastEffect = tag.next = tag) - : ((destroy = create.next), - (create.next = tag), - (tag.next = destroy), - (componentUpdateQueue.lastEffect = tag))); + create = currentlyRenderingFiber$1.updateQueue; + null === create + ? ((create = { lastEffect: null }), + (currentlyRenderingFiber$1.updateQueue = create), + (create.lastEffect = tag.next = tag)) + : ((destroy = create.lastEffect), + null === destroy + ? (create.lastEffect = tag.next = tag) + : ((deps = destroy.next), + (destroy.next = tag), + (tag.next = deps), + (create.lastEffect = tag))); return tag; } function mountEffectImpl(fiberEffectTag, hookEffectTag, create, deps) { var hook = mountWorkInProgressHook(); - sideEffectTag |= fiberEffectTag; + currentlyRenderingFiber$1.effectTag |= fiberEffectTag; hook.memoizedState = pushEffect( hookEffectTag, create, @@ -3457,7 +3402,7 @@ function updateEffectImpl(fiberEffectTag, hookEffectTag, create, deps) { return; } } - sideEffectTag |= fiberEffectTag; + currentlyRenderingFiber$1.effectTag |= fiberEffectTag; hook.memoizedState = pushEffect(hookEffectTag, create, destroy, deps); } function mountEffect(create, deps) { @@ -3505,6 +3450,21 @@ function updateCallback(callback, deps) { hook.memoizedState = [callback, deps]; return callback; } +function startTransition(setPending, config, callback) { + var priorityLevel = getCurrentPriorityLevel(); + runWithPriority(98 > priorityLevel ? 98 : priorityLevel, function() { + setPending(!0); + }); + runWithPriority(97 < priorityLevel ? 97 : priorityLevel, function() { + var previousConfig = ReactCurrentBatchConfig$1.suspense; + ReactCurrentBatchConfig$1.suspense = void 0 === config ? null : config; + try { + setPending(!1), callback(); + } finally { + ReactCurrentBatchConfig$1.suspense = previousConfig; + } + }); +} function dispatchAction(fiber, queue, action) { if (!(25 > numberOfReRenders)) throw Error( @@ -3546,14 +3506,11 @@ function dispatchAction(fiber, queue, action) { eagerState: null, next: null }; - var last = queue.last; - if (null === last) suspenseConfig.next = suspenseConfig; - else { - var first = last.next; - null !== first && (suspenseConfig.next = first); - last.next = suspenseConfig; - } - queue.last = suspenseConfig; + var pending = queue.pending; + null === pending + ? (suspenseConfig.next = suspenseConfig) + : ((suspenseConfig.next = pending.next), (pending.next = suspenseConfig)); + queue.pending = suspenseConfig; if ( 0 === fiber.expirationTime && (null === alternate || 0 === alternate.expirationTime) && @@ -3616,7 +3573,7 @@ var ContextOnlyDispatcher = { initialArg = void 0 !== init ? init(initialArg) : initialArg; hook.memoizedState = hook.baseState = initialArg; reducer = hook.queue = { - last: null, + pending: null, dispatch: null, lastRenderedReducer: reducer, lastRenderedState: initialArg @@ -3635,23 +3592,21 @@ var ContextOnlyDispatcher = { }, useState: mountState, useDebugValue: mountDebugValue, - useResponder: createResponderListener, + useResponder: createDeprecatedResponderListener, useDeferredValue: function(value, config) { var _mountState = mountState(value), prevValue = _mountState[0], setValue = _mountState[1]; mountEffect( function() { - Scheduler.unstable_next(function() { - var previousConfig = ReactCurrentBatchConfig$1.suspense; - ReactCurrentBatchConfig$1.suspense = - void 0 === config ? null : config; - try { - setValue(value); - } finally { - ReactCurrentBatchConfig$1.suspense = previousConfig; - } - }); + var previousConfig = ReactCurrentBatchConfig$1.suspense; + ReactCurrentBatchConfig$1.suspense = + void 0 === config ? null : config; + try { + setValue(value); + } finally { + ReactCurrentBatchConfig$1.suspense = previousConfig; + } }, [value, config] ); @@ -3659,25 +3614,13 @@ var ContextOnlyDispatcher = { }, useTransition: function(config) { var _mountState2 = mountState(!1), - isPending = _mountState2[0], - setPending = _mountState2[1]; + isPending = _mountState2[0]; + _mountState2 = _mountState2[1]; return [ - mountCallback( - function(callback) { - setPending(!0); - Scheduler.unstable_next(function() { - var previousConfig = ReactCurrentBatchConfig$1.suspense; - ReactCurrentBatchConfig$1.suspense = - void 0 === config ? null : config; - try { - setPending(!1), callback(); - } finally { - ReactCurrentBatchConfig$1.suspense = previousConfig; - } - }); - }, - [config, isPending] - ), + mountCallback(startTransition.bind(null, _mountState2, config), [ + _mountState2, + config + ]), isPending ]; } @@ -3719,23 +3662,21 @@ var ContextOnlyDispatcher = { }, useState: updateState, useDebugValue: mountDebugValue, - useResponder: createResponderListener, + useResponder: createDeprecatedResponderListener, useDeferredValue: function(value, config) { var _updateState = updateState(value), prevValue = _updateState[0], setValue = _updateState[1]; updateEffect( function() { - Scheduler.unstable_next(function() { - var previousConfig = ReactCurrentBatchConfig$1.suspense; - ReactCurrentBatchConfig$1.suspense = - void 0 === config ? null : config; - try { - setValue(value); - } finally { - ReactCurrentBatchConfig$1.suspense = previousConfig; - } - }); + var previousConfig = ReactCurrentBatchConfig$1.suspense; + ReactCurrentBatchConfig$1.suspense = + void 0 === config ? null : config; + try { + setValue(value); + } finally { + ReactCurrentBatchConfig$1.suspense = previousConfig; + } }, [value, config] ); @@ -3743,25 +3684,13 @@ var ContextOnlyDispatcher = { }, useTransition: function(config) { var _updateState2 = updateState(!1), - isPending = _updateState2[0], - setPending = _updateState2[1]; + isPending = _updateState2[0]; + _updateState2 = _updateState2[1]; return [ - updateCallback( - function(callback) { - setPending(!0); - Scheduler.unstable_next(function() { - var previousConfig = ReactCurrentBatchConfig$1.suspense; - ReactCurrentBatchConfig$1.suspense = - void 0 === config ? null : config; - try { - setPending(!1), callback(); - } finally { - ReactCurrentBatchConfig$1.suspense = previousConfig; - } - }); - }, - [config, isPending] - ), + updateCallback(startTransition.bind(null, _updateState2, config), [ + _updateState2, + config + ]), isPending ]; } @@ -4075,17 +4004,14 @@ function updateClassComponent( )); hasForceUpdate = !1; var oldState = workInProgress.memoizedState; - oldContext = instance.state = oldState; - var updateQueue = workInProgress.updateQueue; - null !== updateQueue && - (processUpdateQueue( - workInProgress, - updateQueue, - nextProps, - instance, - renderExpirationTime - ), - (oldContext = workInProgress.memoizedState)); + instance.state = oldState; + processUpdateQueue( + workInProgress, + nextProps, + instance, + renderExpirationTime + ); + oldContext = workInProgress.memoizedState; oldProps !== nextProps || oldState !== oldContext || didPerformWorkStackCursor.current || @@ -4131,6 +4057,7 @@ function updateClassComponent( (nextProps = !1)); } else (instance = workInProgress.stateNode), + cloneUpdateQueue(current$$1, workInProgress), (oldProps = workInProgress.memoizedProps), (instance.props = workInProgress.type === workInProgress.elementType @@ -4159,17 +4086,14 @@ function updateClassComponent( )), (hasForceUpdate = !1), (oldContext = workInProgress.memoizedState), - (oldState = instance.state = oldContext), - (updateQueue = workInProgress.updateQueue), - null !== updateQueue && - (processUpdateQueue( - workInProgress, - updateQueue, - nextProps, - instance, - renderExpirationTime - ), - (oldState = workInProgress.memoizedState)), + (instance.state = oldContext), + processUpdateQueue( + workInProgress, + nextProps, + instance, + renderExpirationTime + ), + (oldState = workInProgress.memoizedState), oldProps !== nextProps || oldContext !== oldState || didPerformWorkStackCursor.current || @@ -4471,6 +4395,7 @@ function initSuspenseListRenderState( ? (workInProgress.memoizedState = { isBackwards: isBackwards, rendering: null, + renderingStartTime: 0, last: lastContentRow, tail: tail, tailExpiration: 0, @@ -4479,6 +4404,7 @@ function initSuspenseListRenderState( }) : ((renderState.isBackwards = isBackwards), (renderState.rendering = null), + (renderState.renderingStartTime = 0), (renderState.last = lastContentRow), (renderState.tail = tail), (renderState.tailExpiration = 0), @@ -4685,38 +4611,348 @@ function cutOffTailIfNeeded(renderState, hasRenderedATailFallback) { : (_lastTailNode.sibling = null); } } -function unwindWork(workInProgress) { +function completeWork(current, workInProgress, renderExpirationTime$jscomp$0) { + 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 null; case 1: - isContextProvider(workInProgress.type) && popContext(workInProgress); - var effectTag = workInProgress.effectTag; - return effectTag & 4096 - ? ((workInProgress.effectTag = (effectTag & -4097) | 64), - workInProgress) - : null; + return ( + isContextProvider(workInProgress.type) && popContext(workInProgress), + null + ); case 3: - popHostContainer(workInProgress); - popTopLevelContextObject(workInProgress); - effectTag = workInProgress.effectTag; - if (0 !== (effectTag & 64)) - throw Error( - "The root failed to unmount after an error. This is likely a bug in React. Please file an issue." - ); - workInProgress.effectTag = (effectTag & -4097) | 64; - return workInProgress; + return ( + popHostContainer(workInProgress), + popTopLevelContextObject(workInProgress), + (current = workInProgress.stateNode), + current.pendingContext && + ((current.context = current.pendingContext), + (current.pendingContext = null)), + updateHostContainer(workInProgress), + null + ); case 5: - return popHostContext(workInProgress), null; + popHostContext(workInProgress); + var rootContainerInstance = requiredContext( + rootInstanceStackCursor.current + ); + renderExpirationTime$jscomp$0 = workInProgress.type; + if (null !== current && null != workInProgress.stateNode) + updateHostComponent$1( + current, + workInProgress, + renderExpirationTime$jscomp$0, + newProps, + rootContainerInstance + ), + current.ref !== workInProgress.ref && + (workInProgress.effectTag |= 128); + 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." + ); + return null; + } + current = requiredContext(contextStackCursor$1.current); + var tag = allocateTag(), + viewConfig = getViewConfigForType(renderExpirationTime$jscomp$0), + updatePayload = diffProperties( + null, + emptyObject, + newProps, + viewConfig.validAttributes + ); + ReactNativePrivateInterface.UIManager.createView( + tag, + viewConfig.uiViewClassName, + rootContainerInstance, + updatePayload + ); + viewConfig = new ReactNativeFiberHostComponent(tag, viewConfig); + instanceCache.set(tag, workInProgress); + instanceProps.set(tag, newProps); + appendAllChildren(viewConfig, workInProgress, !1, !1); + workInProgress.stateNode = viewConfig; + finalizeInitialChildren( + viewConfig, + renderExpirationTime$jscomp$0, + newProps, + rootContainerInstance, + current + ) && (workInProgress.effectTag |= 4); + null !== workInProgress.ref && (workInProgress.effectTag |= 128); + } + 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." + ); + rootContainerInstance = allocateTag(); + ReactNativePrivateInterface.UIManager.createView( + rootContainerInstance, + "RCTRawText", + current, + { text: newProps } + ); + instanceCache.set(rootContainerInstance, workInProgress); + workInProgress.stateNode = rootContainerInstance; + } + return null; case 13: + pop(suspenseStackCursor, workInProgress); + newProps = workInProgress.memoizedState; + if (0 !== (workInProgress.effectTag & 64)) + return ( + (workInProgress.expirationTime = renderExpirationTime$jscomp$0), + workInProgress + ); + newProps = null !== newProps; + rootContainerInstance = !1; + null !== current && + ((renderExpirationTime$jscomp$0 = current.memoizedState), + (rootContainerInstance = null !== renderExpirationTime$jscomp$0), + newProps || + null === renderExpirationTime$jscomp$0 || + ((renderExpirationTime$jscomp$0 = current.child.sibling), + null !== renderExpirationTime$jscomp$0 && + ((tag = workInProgress.firstEffect), + null !== tag + ? ((workInProgress.firstEffect = renderExpirationTime$jscomp$0), + (renderExpirationTime$jscomp$0.nextEffect = tag)) + : ((workInProgress.firstEffect = workInProgress.lastEffect = renderExpirationTime$jscomp$0), + (renderExpirationTime$jscomp$0.nextEffect = null)), + (renderExpirationTime$jscomp$0.effectTag = 8)))); + if (newProps && !rootContainerInstance && 0 !== (workInProgress.mode & 2)) + if ( + (null === current && + !0 !== workInProgress.memoizedProps.unstable_avoidThisFallback) || + 0 !== (suspenseStackCursor.current & 1) + ) + workInProgressRootExitStatus === RootIncomplete && + (workInProgressRootExitStatus = RootSuspended); + else { + if ( + workInProgressRootExitStatus === RootIncomplete || + workInProgressRootExitStatus === RootSuspended + ) + workInProgressRootExitStatus = RootSuspendedWithDelay; + 0 !== workInProgressRootNextUnprocessedUpdateTime && + null !== workInProgressRoot && + (markRootSuspendedAtTime(workInProgressRoot, renderExpirationTime), + markRootUpdatedAtTime( + workInProgressRoot, + workInProgressRootNextUnprocessedUpdateTime + )); + } + if (newProps || rootContainerInstance) workInProgress.effectTag |= 4; + return null; + case 4: return ( - pop(suspenseStackCursor, workInProgress), - (effectTag = workInProgress.effectTag), - effectTag & 4096 - ? ((workInProgress.effectTag = (effectTag & -4097) | 64), - workInProgress) - : null + popHostContainer(workInProgress), + updateHostContainer(workInProgress), + null ); - case 19: - return pop(suspenseStackCursor, workInProgress), null; + case 10: + return popProvider(workInProgress), null; + case 17: + return ( + isContextProvider(workInProgress.type) && popContext(workInProgress), + null + ); + case 19: + pop(suspenseStackCursor, workInProgress); + newProps = workInProgress.memoizedState; + if (null === newProps) return null; + rootContainerInstance = 0 !== (workInProgress.effectTag & 64); + tag = newProps.rendering; + if (null === tag) + if (rootContainerInstance) cutOffTailIfNeeded(newProps, !1); + else { + if ( + workInProgressRootExitStatus !== RootIncomplete || + (null !== current && 0 !== (current.effectTag & 64)) + ) + for (current = workInProgress.child; null !== current; ) { + tag = findFirstSuspended(current); + if (null !== tag) { + workInProgress.effectTag |= 64; + cutOffTailIfNeeded(newProps, !1); + current = tag.updateQueue; + null !== current && + ((workInProgress.updateQueue = current), + (workInProgress.effectTag |= 4)); + null === newProps.lastEffect && + (workInProgress.firstEffect = null); + workInProgress.lastEffect = newProps.lastEffect; + current = renderExpirationTime$jscomp$0; + for (newProps = workInProgress.child; null !== newProps; ) + (rootContainerInstance = newProps), + (renderExpirationTime$jscomp$0 = current), + (rootContainerInstance.effectTag &= 2), + (rootContainerInstance.nextEffect = null), + (rootContainerInstance.firstEffect = null), + (rootContainerInstance.lastEffect = null), + (tag = rootContainerInstance.alternate), + null === tag + ? ((rootContainerInstance.childExpirationTime = 0), + (rootContainerInstance.expirationTime = renderExpirationTime$jscomp$0), + (rootContainerInstance.child = null), + (rootContainerInstance.memoizedProps = null), + (rootContainerInstance.memoizedState = null), + (rootContainerInstance.updateQueue = null), + (rootContainerInstance.dependencies = null)) + : ((rootContainerInstance.childExpirationTime = + tag.childExpirationTime), + (rootContainerInstance.expirationTime = + tag.expirationTime), + (rootContainerInstance.child = tag.child), + (rootContainerInstance.memoizedProps = + tag.memoizedProps), + (rootContainerInstance.memoizedState = + tag.memoizedState), + (rootContainerInstance.updateQueue = tag.updateQueue), + (renderExpirationTime$jscomp$0 = tag.dependencies), + (rootContainerInstance.dependencies = + null === renderExpirationTime$jscomp$0 + ? null + : { + expirationTime: + renderExpirationTime$jscomp$0.expirationTime, + firstContext: + renderExpirationTime$jscomp$0.firstContext, + responders: + renderExpirationTime$jscomp$0.responders + })), + (newProps = newProps.sibling); + push( + suspenseStackCursor, + (suspenseStackCursor.current & 1) | 2, + workInProgress + ); + return workInProgress.child; + } + current = current.sibling; + } + } + else { + if (!rootContainerInstance) + if (((current = findFirstSuspended(tag)), null !== current)) { + if ( + ((workInProgress.effectTag |= 64), + (rootContainerInstance = !0), + (current = current.updateQueue), + null !== current && + ((workInProgress.updateQueue = current), + (workInProgress.effectTag |= 4)), + cutOffTailIfNeeded(newProps, !0), + null === newProps.tail && + "hidden" === newProps.tailMode && + !tag.alternate) + ) + return ( + (workInProgress = workInProgress.lastEffect = + newProps.lastEffect), + null !== workInProgress && (workInProgress.nextEffect = null), + null + ); + } else + 2 * now() - newProps.renderingStartTime > newProps.tailExpiration && + 1 < renderExpirationTime$jscomp$0 && + ((workInProgress.effectTag |= 64), + (rootContainerInstance = !0), + cutOffTailIfNeeded(newProps, !1), + (workInProgress.expirationTime = workInProgress.childExpirationTime = + renderExpirationTime$jscomp$0 - 1)); + newProps.isBackwards + ? ((tag.sibling = workInProgress.child), (workInProgress.child = tag)) + : ((current = newProps.last), + null !== current + ? (current.sibling = tag) + : (workInProgress.child = tag), + (newProps.last = tag)); + } + return null !== newProps.tail + ? (0 === newProps.tailExpiration && + (newProps.tailExpiration = now() + 500), + (current = newProps.tail), + (newProps.rendering = current), + (newProps.tail = current.sibling), + (newProps.lastEffect = workInProgress.lastEffect), + (newProps.renderingStartTime = now()), + (current.sibling = null), + (newProps = suspenseStackCursor.current), + push( + suspenseStackCursor, + rootContainerInstance ? (newProps & 1) | 2 : newProps & 1, + workInProgress + ), + current) + : null; + } + throw 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) { + switch (workInProgress.tag) { + case 1: + isContextProvider(workInProgress.type) && popContext(workInProgress); + var effectTag = workInProgress.effectTag; + return effectTag & 4096 + ? ((workInProgress.effectTag = (effectTag & -4097) | 64), + workInProgress) + : null; + case 3: + popHostContainer(workInProgress); + popTopLevelContextObject(workInProgress); + effectTag = workInProgress.effectTag; + if (0 !== (effectTag & 64)) + throw Error( + "The root failed to unmount after an error. This is likely a bug in React. Please file an issue." + ); + workInProgress.effectTag = (effectTag & -4097) | 64; + return workInProgress; + case 5: + return popHostContext(workInProgress), null; + case 13: + return ( + pop(suspenseStackCursor, workInProgress), + (effectTag = workInProgress.effectTag), + effectTag & 4096 + ? ((workInProgress.effectTag = (effectTag & -4097) | 64), + workInProgress) + : null + ); + case 19: + return pop(suspenseStackCursor, workInProgress), null; case 4: return popHostContainer(workInProgress), null; case 10: @@ -4800,8 +5036,9 @@ function commitBeforeMutationLifeCycles(current$$1, finishedWork) { case 0: case 11: case 15: + case 22: commitHookEffectList(2, 0, finishedWork); - break; + return; case 1: if (finishedWork.effectTag & 256 && null !== current$$1) { var prevProps = current$$1.memoizedProps, @@ -4815,18 +5052,17 @@ function commitBeforeMutationLifeCycles(current$$1, finishedWork) { ); current$$1.__reactInternalSnapshotBeforeUpdate = finishedWork; } - break; + return; case 3: case 5: case 6: case 4: case 17: - 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." - ); + return; } + throw Error( + "This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue." + ); } function commitHookEffectList(unmountTag, mountTag, finishedWork) { finishedWork = finishedWork.updateQueue; @@ -4845,6 +5081,86 @@ function commitHookEffectList(unmountTag, mountTag, finishedWork) { } while (effect !== finishedWork); } } +function commitLifeCycles( + finishedRoot, + current$$1, + finishedWork, + committedExpirationTime +) { + switch (finishedWork.tag) { + case 0: + case 11: + case 15: + case 22: + commitHookEffectList(16, 32, finishedWork); + return; + case 1: + finishedRoot = finishedWork.stateNode; + if (finishedWork.effectTag & 4) + if (null === current$$1) finishedRoot.componentDidMount(); + else { + var prevProps = + finishedWork.elementType === finishedWork.type + ? current$$1.memoizedProps + : resolveDefaultProps( + finishedWork.type, + current$$1.memoizedProps + ); + finishedRoot.componentDidUpdate( + prevProps, + current$$1.memoizedState, + finishedRoot.__reactInternalSnapshotBeforeUpdate + ); + } + current$$1 = finishedWork.updateQueue; + null !== current$$1 && + commitUpdateQueue( + finishedWork, + current$$1, + finishedRoot, + committedExpirationTime + ); + return; + case 3: + current$$1 = finishedWork.updateQueue; + if (null !== current$$1) { + finishedRoot = null; + if (null !== finishedWork.child) + switch (finishedWork.child.tag) { + case 5: + finishedRoot = finishedWork.child.stateNode; + break; + case 1: + finishedRoot = finishedWork.child.stateNode; + } + commitUpdateQueue( + finishedWork, + current$$1, + finishedRoot, + committedExpirationTime + ); + } + return; + case 5: + return; + case 6: + return; + case 4: + return; + case 12: + return; + case 13: + return; + case 19: + case 17: + case 20: + case 21: + return; + } + throw Error( + "This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue." + ); +} function commitUnmount(finishedRoot, current$$1$jscomp$0, renderPriorityLevel) { "function" === typeof onCommitFiberUnmount && onCommitFiberUnmount(current$$1$jscomp$0); @@ -4853,6 +5169,7 @@ function commitUnmount(finishedRoot, current$$1$jscomp$0, renderPriorityLevel) { case 11: case 14: case 15: + case 22: finishedRoot = current$$1$jscomp$0.updateQueue; if ( null !== finishedRoot && @@ -4911,6 +5228,7 @@ function detachFiber(current$$1) { current$$1.lastEffect = null; current$$1.pendingProps = null; current$$1.memoizedProps = null; + current$$1.stateNode = null; null !== alternate && detachFiber(alternate); } function isHostParent(fiber) { @@ -5177,10 +5495,11 @@ function commitWork(current$$1, finishedWork) { case 11: case 14: case 15: + case 22: commitHookEffectList(4, 8, finishedWork); - break; + return; case 1: - break; + return; case 5: var instance = finishedWork.stateNode; if (null != instance) { @@ -5204,7 +5523,7 @@ function commitWork(current$$1, finishedWork) { newProps )); } - break; + return; case 6: if (null === finishedWork.stateNode) throw Error( @@ -5215,11 +5534,11 @@ function commitWork(current$$1, finishedWork) { "RCTRawText", { text: finishedWork.memoizedProps } ); - break; + return; case 3: - break; + return; case 12: - break; + return; case 13: instance = finishedWork; null === finishedWork.memoizedState @@ -5289,21 +5608,16 @@ function commitWork(current$$1, finishedWork) { current$$1 = current$$1.sibling; } attachSuspenseRetryListeners(finishedWork); - break; + return; case 19: attachSuspenseRetryListeners(finishedWork); - break; + return; case 17: - break; - case 20: - break; - case 21: - 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." - ); + return; } + throw Error( + "This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue." + ); } function attachSuspenseRetryListeners(finishedWork) { var thenables = finishedWork.updateQueue; @@ -5775,44 +6089,41 @@ function performConcurrentWorkOnRoot(root, didTimeout) { function performSyncWorkOnRoot(root) { var lastExpiredTime = root.lastExpiredTime; lastExpiredTime = 0 !== lastExpiredTime ? lastExpiredTime : 1073741823; - if (root.finishedExpirationTime === lastExpiredTime) commitRoot(root); - else { - if ((executionContext & (RenderContext | CommitContext)) !== NoContext) - throw Error("Should not already be working."); - flushPassiveEffects(); - (root === workInProgressRoot && lastExpiredTime === renderExpirationTime) || - prepareFreshStack(root, lastExpiredTime); - if (null !== workInProgress) { - var prevExecutionContext = executionContext; - executionContext |= RenderContext; - var prevDispatcher = pushDispatcher(root); - do - try { - workLoopSync(); - break; - } catch (thrownValue) { - handleError(root, thrownValue); - } - while (1); - resetContextDependencies(); - executionContext = prevExecutionContext; - ReactCurrentDispatcher.current = prevDispatcher; - if (workInProgressRootExitStatus === RootFatalErrored) - throw ((prevExecutionContext = workInProgressRootFatalError), - prepareFreshStack(root, lastExpiredTime), - markRootSuspendedAtTime(root, lastExpiredTime), - ensureRootIsScheduled(root), - prevExecutionContext); - if (null !== workInProgress) - throw Error( - "Cannot commit an incomplete root. This error is likely caused by a bug in React. Please file an issue." - ); - root.finishedWork = root.current.alternate; - root.finishedExpirationTime = lastExpiredTime; - workInProgressRoot = null; - commitRoot(root); - ensureRootIsScheduled(root); - } + if ((executionContext & (RenderContext | CommitContext)) !== NoContext) + throw Error("Should not already be working."); + flushPassiveEffects(); + (root === workInProgressRoot && lastExpiredTime === renderExpirationTime) || + prepareFreshStack(root, lastExpiredTime); + if (null !== workInProgress) { + var prevExecutionContext = executionContext; + executionContext |= RenderContext; + var prevDispatcher = pushDispatcher(root); + do + try { + workLoopSync(); + break; + } catch (thrownValue) { + handleError(root, thrownValue); + } + while (1); + resetContextDependencies(); + executionContext = prevExecutionContext; + ReactCurrentDispatcher.current = prevDispatcher; + if (workInProgressRootExitStatus === RootFatalErrored) + throw ((prevExecutionContext = workInProgressRootFatalError), + prepareFreshStack(root, lastExpiredTime), + markRootSuspendedAtTime(root, lastExpiredTime), + ensureRootIsScheduled(root), + prevExecutionContext); + if (null !== workInProgress) + throw Error( + "Cannot commit an incomplete root. This error is likely caused by a bug in React. Please file an issue." + ); + root.finishedWork = root.current.alternate; + root.finishedExpirationTime = lastExpiredTime; + workInProgressRoot = null; + commitRoot(root); + ensureRootIsScheduled(root); } return null; } @@ -5898,8 +6209,15 @@ function handleError(root$jscomp$0, thrownValue) { "object" === typeof value && "function" === typeof value.then ) { - var thenable = value, - hasInvisibleParentBoundary = + var thenable = value; + if (0 === (sourceFiber.mode & 2)) { + var currentSource = sourceFiber.alternate; + currentSource + ? ((sourceFiber.memoizedState = currentSource.memoizedState), + (sourceFiber.expirationTime = currentSource.expirationTime)) + : (sourceFiber.memoizedState = null); + } + var hasInvisibleParentBoundary = 0 !== (suspenseStackCursor.current & 1), _workInProgress = returnFiber; do { @@ -6067,361 +6385,30 @@ function completeUnitOfWork(unitOfWork) { var current$$1 = workInProgress.alternate; unitOfWork = workInProgress.return; if (0 === (workInProgress.effectTag & 2048)) { - a: { - var current = current$$1; - current$$1 = workInProgress; - var renderExpirationTime$jscomp$0 = renderExpirationTime, - newProps = current$$1.pendingProps; - switch (current$$1.tag) { - case 2: - break; - case 16: - break; - case 15: - case 0: - break; - case 1: - isContextProvider(current$$1.type) && popContext(current$$1); - break; - case 3: - popHostContainer(current$$1); - popTopLevelContextObject(current$$1); - current = current$$1.stateNode; - current.pendingContext && - ((current.context = current.pendingContext), - (current.pendingContext = null)); - updateHostContainer(current$$1); - break; - case 5: - popHostContext(current$$1); - var rootContainerInstance = requiredContext( - rootInstanceStackCursor.current - ); - renderExpirationTime$jscomp$0 = current$$1.type; - if (null !== current && null != current$$1.stateNode) - updateHostComponent$1( - current, - current$$1, - renderExpirationTime$jscomp$0, - newProps, - rootContainerInstance - ), - current.ref !== current$$1.ref && (current$$1.effectTag |= 128); - else if (newProps) { - current = requiredContext(contextStackCursor$1.current); - var internalInstanceHandle = current$$1, - tag = allocateTag(), - viewConfig = getViewConfigForType( - renderExpirationTime$jscomp$0 - ), - updatePayload = diffProperties( - null, - emptyObject, - newProps, - viewConfig.validAttributes - ); - ReactNativePrivateInterface.UIManager.createView( - tag, - viewConfig.uiViewClassName, - rootContainerInstance, - updatePayload - ); - viewConfig = new ReactNativeFiberHostComponent(tag, viewConfig); - instanceCache.set(tag, internalInstanceHandle); - instanceProps.set(tag, newProps); - appendAllChildren(viewConfig, current$$1, !1, !1); - current$$1.stateNode = viewConfig; - finalizeInitialChildren( - viewConfig, - renderExpirationTime$jscomp$0, - newProps, - rootContainerInstance, - current - ) && (current$$1.effectTag |= 4); - null !== current$$1.ref && (current$$1.effectTag |= 128); - } else if (null === current$$1.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." - ); - break; - case 6: - if (current && null != current$$1.stateNode) - updateHostText$1( - current, - current$$1, - current.memoizedProps, - newProps - ); - else { - if ("string" !== typeof newProps && null === current$$1.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." - ); - renderExpirationTime$jscomp$0 = requiredContext( - rootInstanceStackCursor.current - ); - rootContainerInstance = requiredContext( - contextStackCursor$1.current - ); - current = current$$1; - if (!rootContainerInstance.isInAParentText) - throw Error( - "Text strings must be rendered within a component." - ); - rootContainerInstance = allocateTag(); - ReactNativePrivateInterface.UIManager.createView( - rootContainerInstance, - "RCTRawText", - renderExpirationTime$jscomp$0, - { text: newProps } - ); - instanceCache.set(rootContainerInstance, current$$1); - current.stateNode = rootContainerInstance; - } - break; - case 11: - break; - case 13: - pop(suspenseStackCursor, current$$1); - newProps = current$$1.memoizedState; - if (0 !== (current$$1.effectTag & 64)) { - current$$1.expirationTime = renderExpirationTime$jscomp$0; - break a; - } - newProps = null !== newProps; - rootContainerInstance = !1; - null !== current && - ((renderExpirationTime$jscomp$0 = current.memoizedState), - (rootContainerInstance = null !== renderExpirationTime$jscomp$0), - newProps || - null === renderExpirationTime$jscomp$0 || - ((renderExpirationTime$jscomp$0 = current.child.sibling), - null !== renderExpirationTime$jscomp$0 && - ((internalInstanceHandle = current$$1.firstEffect), - null !== internalInstanceHandle - ? ((current$$1.firstEffect = renderExpirationTime$jscomp$0), - (renderExpirationTime$jscomp$0.nextEffect = internalInstanceHandle)) - : ((current$$1.firstEffect = current$$1.lastEffect = renderExpirationTime$jscomp$0), - (renderExpirationTime$jscomp$0.nextEffect = null)), - (renderExpirationTime$jscomp$0.effectTag = 8)))); - if ( - newProps && - !rootContainerInstance && - 0 !== (current$$1.mode & 2) - ) - if ( - (null === current && - !0 !== current$$1.memoizedProps.unstable_avoidThisFallback) || - 0 !== (suspenseStackCursor.current & 1) - ) - workInProgressRootExitStatus === RootIncomplete && - (workInProgressRootExitStatus = RootSuspended); - else { - if ( - workInProgressRootExitStatus === RootIncomplete || - workInProgressRootExitStatus === RootSuspended - ) - workInProgressRootExitStatus = RootSuspendedWithDelay; - 0 !== workInProgressRootNextUnprocessedUpdateTime && - null !== workInProgressRoot && - (markRootSuspendedAtTime( - workInProgressRoot, - renderExpirationTime - ), - markRootUpdatedAtTime( - workInProgressRoot, - workInProgressRootNextUnprocessedUpdateTime - )); - } - if (newProps || rootContainerInstance) current$$1.effectTag |= 4; - break; - case 7: - break; - case 8: - break; - case 12: - break; - case 4: - popHostContainer(current$$1); - updateHostContainer(current$$1); - break; - case 10: - popProvider(current$$1); - break; - case 9: - break; - case 14: - break; - case 17: - isContextProvider(current$$1.type) && popContext(current$$1); - break; - case 19: - pop(suspenseStackCursor, current$$1); - newProps = current$$1.memoizedState; - if (null === newProps) break; - rootContainerInstance = 0 !== (current$$1.effectTag & 64); - internalInstanceHandle = newProps.rendering; - if (null === internalInstanceHandle) - if (rootContainerInstance) cutOffTailIfNeeded(newProps, !1); - else { - if ( - workInProgressRootExitStatus !== RootIncomplete || - (null !== current && 0 !== (current.effectTag & 64)) - ) - for (current = current$$1.child; null !== current; ) { - internalInstanceHandle = findFirstSuspended(current); - if (null !== internalInstanceHandle) { - current$$1.effectTag |= 64; - cutOffTailIfNeeded(newProps, !1); - current = internalInstanceHandle.updateQueue; - null !== current && - ((current$$1.updateQueue = current), - (current$$1.effectTag |= 4)); - null === newProps.lastEffect && - (current$$1.firstEffect = null); - current$$1.lastEffect = newProps.lastEffect; - current = renderExpirationTime$jscomp$0; - for (newProps = current$$1.child; null !== newProps; ) - (rootContainerInstance = newProps), - (renderExpirationTime$jscomp$0 = current), - (rootContainerInstance.effectTag &= 2), - (rootContainerInstance.nextEffect = null), - (rootContainerInstance.firstEffect = null), - (rootContainerInstance.lastEffect = null), - (internalInstanceHandle = - rootContainerInstance.alternate), - null === internalInstanceHandle - ? ((rootContainerInstance.childExpirationTime = 0), - (rootContainerInstance.expirationTime = renderExpirationTime$jscomp$0), - (rootContainerInstance.child = null), - (rootContainerInstance.memoizedProps = null), - (rootContainerInstance.memoizedState = null), - (rootContainerInstance.updateQueue = null), - (rootContainerInstance.dependencies = null)) - : ((rootContainerInstance.childExpirationTime = - internalInstanceHandle.childExpirationTime), - (rootContainerInstance.expirationTime = - internalInstanceHandle.expirationTime), - (rootContainerInstance.child = - internalInstanceHandle.child), - (rootContainerInstance.memoizedProps = - internalInstanceHandle.memoizedProps), - (rootContainerInstance.memoizedState = - internalInstanceHandle.memoizedState), - (rootContainerInstance.updateQueue = - internalInstanceHandle.updateQueue), - (renderExpirationTime$jscomp$0 = - internalInstanceHandle.dependencies), - (rootContainerInstance.dependencies = - null === renderExpirationTime$jscomp$0 - ? null - : { - expirationTime: - renderExpirationTime$jscomp$0.expirationTime, - firstContext: - renderExpirationTime$jscomp$0.firstContext, - responders: - renderExpirationTime$jscomp$0.responders - })), - (newProps = newProps.sibling); - push( - suspenseStackCursor, - (suspenseStackCursor.current & 1) | 2, - current$$1 - ); - current$$1 = current$$1.child; - break a; - } - current = current.sibling; - } - } - else { - if (!rootContainerInstance) - if ( - ((current = findFirstSuspended(internalInstanceHandle)), - null !== current) - ) { - if ( - ((current$$1.effectTag |= 64), - (rootContainerInstance = !0), - (current = current.updateQueue), - null !== current && - ((current$$1.updateQueue = current), - (current$$1.effectTag |= 4)), - cutOffTailIfNeeded(newProps, !0), - null === newProps.tail && - "hidden" === newProps.tailMode && - !internalInstanceHandle.alternate) - ) { - current$$1 = current$$1.lastEffect = newProps.lastEffect; - null !== current$$1 && (current$$1.nextEffect = null); - break; - } - } else - now() > newProps.tailExpiration && - 1 < renderExpirationTime$jscomp$0 && - ((current$$1.effectTag |= 64), - (rootContainerInstance = !0), - cutOffTailIfNeeded(newProps, !1), - (current$$1.expirationTime = current$$1.childExpirationTime = - renderExpirationTime$jscomp$0 - 1)); - newProps.isBackwards - ? ((internalInstanceHandle.sibling = current$$1.child), - (current$$1.child = internalInstanceHandle)) - : ((current = newProps.last), - null !== current - ? (current.sibling = internalInstanceHandle) - : (current$$1.child = internalInstanceHandle), - (newProps.last = internalInstanceHandle)); - } - if (null !== newProps.tail) { - 0 === newProps.tailExpiration && - (newProps.tailExpiration = now() + 500); - current = newProps.tail; - newProps.rendering = current; - newProps.tail = current.sibling; - newProps.lastEffect = current$$1.lastEffect; - current.sibling = null; - newProps = suspenseStackCursor.current; - newProps = rootContainerInstance - ? (newProps & 1) | 2 - : newProps & 1; - push(suspenseStackCursor, newProps, current$$1); - current$$1 = current; - break a; - } - break; - case 20: - break; - case 21: - break; - default: - throw Error( - "Unknown unit of work tag (" + - current$$1.tag + - "). This error is likely caused by a bug in React. Please file an issue." - ); - } - current$$1 = null; - } - current = workInProgress; - if (1 === renderExpirationTime || 1 !== current.childExpirationTime) { - newProps = 0; + current$$1 = completeWork( + current$$1, + workInProgress, + renderExpirationTime + ); + var completedWork = workInProgress; + if ( + 1 === renderExpirationTime || + 1 !== completedWork.childExpirationTime + ) { for ( - rootContainerInstance = current.child; - null !== rootContainerInstance; + var newChildExpirationTime = 0, _child = completedWork.child; + null !== _child; - ) - (renderExpirationTime$jscomp$0 = - rootContainerInstance.expirationTime), - (internalInstanceHandle = - rootContainerInstance.childExpirationTime), - renderExpirationTime$jscomp$0 > newProps && - (newProps = renderExpirationTime$jscomp$0), - internalInstanceHandle > newProps && - (newProps = internalInstanceHandle), - (rootContainerInstance = rootContainerInstance.sibling); - current.childExpirationTime = newProps; + ) { + var _childUpdateExpirationTime = _child.expirationTime, + _childChildExpirationTime = _child.childExpirationTime; + _childUpdateExpirationTime > newChildExpirationTime && + (newChildExpirationTime = _childUpdateExpirationTime); + _childChildExpirationTime > newChildExpirationTime && + (newChildExpirationTime = _childChildExpirationTime); + _child = _child.sibling; + } + completedWork.childExpirationTime = newChildExpirationTime; } if (null !== current$$1) return current$$1; null !== unitOfWork && @@ -6464,7 +6451,8 @@ function commitRoot(root) { return null; } function commitRootImpl(root$jscomp$0, renderPriorityLevel$jscomp$0) { - flushPassiveEffects(); + do flushPassiveEffects(); + while (null !== rootWithPendingPassiveEffects); if ((executionContext & (RenderContext | CommitContext)) !== NoContext) throw Error("Should not already be working."); var finishedWork = root$jscomp$0.finishedWork, @@ -6575,97 +6563,34 @@ function commitRootImpl(root$jscomp$0, renderPriorityLevel$jscomp$0) { nextEffect = remainingExpirationTimeBeforeCommit; do try { - for (effectTag = expirationTime; null !== nextEffect; ) { + for ( + effectTag = root$jscomp$0, current$$1 = expirationTime; + null !== nextEffect; + + ) { var effectTag$jscomp$0 = nextEffect.effectTag; - if (effectTag$jscomp$0 & 36) { - var current$$1$jscomp$1 = nextEffect.alternate; - current$$1 = nextEffect; - currentRef = effectTag; - switch (current$$1.tag) { - case 0: - case 11: - case 15: - commitHookEffectList(16, 32, current$$1); - break; - case 1: - var instance = current$$1.stateNode; - if (current$$1.effectTag & 4) - if (null === current$$1$jscomp$1) - instance.componentDidMount(); - else { - var prevProps = - current$$1.elementType === current$$1.type - ? current$$1$jscomp$1.memoizedProps - : resolveDefaultProps( - current$$1.type, - current$$1$jscomp$1.memoizedProps - ); - instance.componentDidUpdate( - prevProps, - current$$1$jscomp$1.memoizedState, - instance.__reactInternalSnapshotBeforeUpdate - ); - } - var updateQueue = current$$1.updateQueue; - null !== updateQueue && - commitUpdateQueue( - current$$1, - updateQueue, - instance, - currentRef - ); - break; - case 3: - var _updateQueue = current$$1.updateQueue; - if (null !== _updateQueue) { - root = null; - if (null !== current$$1.child) - switch (current$$1.child.tag) { - case 5: - root = current$$1.child.stateNode; - break; - case 1: - root = current$$1.child.stateNode; - } - commitUpdateQueue(current$$1, _updateQueue, root, currentRef); - } - break; - case 5: - break; - case 6: - break; - case 4: - break; - case 12: - break; - case 13: - break; - case 19: - case 17: - case 20: - case 21: - 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." - ); - } - } + effectTag$jscomp$0 & 36 && + commitLifeCycles( + effectTag, + nextEffect.alternate, + nextEffect, + current$$1 + ); if (effectTag$jscomp$0 & 128) { - current$$1 = void 0; + currentRef = void 0; var ref = nextEffect.ref; if (null !== ref) { - var instance$jscomp$0 = nextEffect.stateNode; + var instance = nextEffect.stateNode; switch (nextEffect.tag) { case 5: - current$$1 = instance$jscomp$0; + currentRef = instance; break; default: - current$$1 = instance$jscomp$0; + currentRef = instance; } "function" === typeof ref - ? ref(current$$1) - : (ref.current = current$$1); + ? ref(currentRef) + : (ref.current = currentRef); } } nextEffect = nextEffect.nextEffect; @@ -6754,6 +6679,7 @@ function flushPassiveEffectsImpl() { case 0: case 11: case 15: + case 22: commitHookEffectList(128, 0, finishedWork), commitHookEffectList(0, 64, finishedWork); } @@ -6963,6 +6889,7 @@ beginWork$$1 = function(current$$1, workInProgress, renderExpirationTime) { null !== renderState.state && void 0 !== renderState.state ? renderState.state : null; + initializeUpdateQueue(workInProgress); var getDerivedStateFromProps = updateExpirationTime.getDerivedStateFromProps; "function" === typeof getDerivedStateFromProps && @@ -7000,62 +6927,63 @@ beginWork$$1 = function(current$$1, workInProgress, renderExpirationTime) { (workInProgress = workInProgress.child); return workInProgress; case 16: - renderState = workInProgress.elementType; - null !== current$$1 && - ((current$$1.alternate = null), - (workInProgress.alternate = null), - (workInProgress.effectTag |= 2)); - current$$1 = workInProgress.pendingProps; - initializeLazyComponentType(renderState); - if (1 !== renderState._status) throw renderState._result; - renderState = renderState._result; - workInProgress.type = renderState; - hasContext = workInProgress.tag = resolveLazyComponentTag(renderState); - current$$1 = resolveDefaultProps(renderState, current$$1); - switch (hasContext) { - case 0: - workInProgress = updateFunctionComponent( - null, - workInProgress, - renderState, - current$$1, - renderExpirationTime - ); - break; - case 1: - workInProgress = updateClassComponent( - null, - workInProgress, - renderState, - current$$1, - renderExpirationTime - ); - break; - case 11: - workInProgress = updateForwardRef( - null, - workInProgress, - renderState, - current$$1, - renderExpirationTime - ); - break; - case 14: - workInProgress = updateMemoComponent( - null, - workInProgress, - renderState, - resolveDefaultProps(renderState.type, current$$1), - updateExpirationTime, - renderExpirationTime - ); - break; - default: - throw Error( - "Element type is invalid. Received a promise that resolves to: " + - renderState + - ". Lazy element type must resolve to a class or function." - ); + a: { + renderState = workInProgress.elementType; + null !== current$$1 && + ((current$$1.alternate = null), + (workInProgress.alternate = null), + (workInProgress.effectTag |= 2)); + current$$1 = workInProgress.pendingProps; + initializeLazyComponentType(renderState); + if (1 !== renderState._status) throw renderState._result; + renderState = renderState._result; + workInProgress.type = renderState; + hasContext = workInProgress.tag = resolveLazyComponentTag(renderState); + current$$1 = resolveDefaultProps(renderState, current$$1); + switch (hasContext) { + case 0: + workInProgress = updateFunctionComponent( + null, + workInProgress, + renderState, + current$$1, + renderExpirationTime + ); + break a; + case 1: + workInProgress = updateClassComponent( + null, + workInProgress, + renderState, + current$$1, + renderExpirationTime + ); + break a; + case 11: + workInProgress = updateForwardRef( + null, + workInProgress, + renderState, + current$$1, + renderExpirationTime + ); + break a; + case 14: + workInProgress = updateMemoComponent( + null, + workInProgress, + renderState, + resolveDefaultProps(renderState.type, current$$1), + updateExpirationTime, + renderExpirationTime + ); + break a; + } + throw Error( + "Element type is invalid. Received a promise that resolves to: " + + renderState + + ". Lazy element type must resolve to a class or function." + ); } return workInProgress; case 0: @@ -7093,16 +7021,17 @@ beginWork$$1 = function(current$$1, workInProgress, renderExpirationTime) { case 3: pushHostRootContext(workInProgress); updateExpirationTime = workInProgress.updateQueue; - if (null === updateExpirationTime) + if (null === current$$1 || null === updateExpirationTime) throw Error( "If the root does not have an updateQueue, we should have already bailed out. This error is likely caused by a bug in React. Please file an issue." ); + updateExpirationTime = workInProgress.pendingProps; renderState = workInProgress.memoizedState; renderState = null !== renderState ? renderState.element : null; + cloneUpdateQueue(current$$1, workInProgress); processUpdateQueue( workInProgress, updateExpirationTime, - workInProgress.pendingProps, null, renderExpirationTime ); @@ -7586,6 +7515,9 @@ function createFiberFromTypeAndProps( fiberTag = 16; owner = null; break a; + case REACT_CHUNK_TYPE: + fiberTag = 22; + break a; } throw Error( "Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: " + @@ -7906,11 +7838,17 @@ var roots = new Map(), findNodeHandle: findNodeHandle, dispatchCommand: function(handle, command, args) { null != handle._nativeTag && - ReactNativePrivateInterface.UIManager.dispatchViewManagerCommand( - handle._nativeTag, - command, - args - ); + (handle._internalInstanceHandle + ? nativeFabricUIManager.dispatchCommand( + handle._internalInstanceHandle.stateNode.node, + command, + args + ) + : ReactNativePrivateInterface.UIManager.dispatchViewManagerCommand( + handle._nativeTag, + command, + args + )); }, render: function(element, containerTag, callback) { var root = roots.get(containerTag); @@ -7919,6 +7857,7 @@ var roots = new Map(), var uninitializedFiber = createFiber(3, null, null, 0); root.current = uninitializedFiber; uninitializedFiber.stateNode = root; + initializeUpdateQueue(uninitializedFiber); roots.set(containerTag, root); } updateContainer(element, root, null, callback); @@ -8078,7 +8017,7 @@ var roots = new Map(), throw Error("getInspectorDataForViewTag() is not available in production"); }, bundleType: 0, - version: "16.11.0", + version: "16.12.0-19f6fe170", rendererPackageName: "react-native-renderer" }); var ReactNativeRenderer$2 = { default: ReactNativeRenderer }, diff --git a/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.fb.js b/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.fb.js index b6719c3c3ecd50..955ccea4e41fec 100644 --- a/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.fb.js +++ b/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.fb.js @@ -503,53 +503,27 @@ function recordTouchStart(touch) { } function recordTouchMove(touch) { var touchRecord = touchBank[getTouchIdentifier(touch)]; - touchRecord - ? ((touchRecord.touchActive = !0), - (touchRecord.previousPageX = touchRecord.currentPageX), - (touchRecord.previousPageY = touchRecord.currentPageY), - (touchRecord.previousTimeStamp = touchRecord.currentTimeStamp), - (touchRecord.currentPageX = touch.pageX), - (touchRecord.currentPageY = touch.pageY), - (touchRecord.currentTimeStamp = timestampForTouch(touch)), - (touchHistory.mostRecentTimeStamp = timestampForTouch(touch))) - : console.warn( - "Cannot record touch move without a touch start.\nTouch Move: %s\n", - "Touch Bank: %s", - printTouch(touch), - printTouchBank() - ); + touchRecord && + ((touchRecord.touchActive = !0), + (touchRecord.previousPageX = touchRecord.currentPageX), + (touchRecord.previousPageY = touchRecord.currentPageY), + (touchRecord.previousTimeStamp = touchRecord.currentTimeStamp), + (touchRecord.currentPageX = touch.pageX), + (touchRecord.currentPageY = touch.pageY), + (touchRecord.currentTimeStamp = timestampForTouch(touch)), + (touchHistory.mostRecentTimeStamp = timestampForTouch(touch))); } function recordTouchEnd(touch) { var touchRecord = touchBank[getTouchIdentifier(touch)]; - touchRecord - ? ((touchRecord.touchActive = !1), - (touchRecord.previousPageX = touchRecord.currentPageX), - (touchRecord.previousPageY = touchRecord.currentPageY), - (touchRecord.previousTimeStamp = touchRecord.currentTimeStamp), - (touchRecord.currentPageX = touch.pageX), - (touchRecord.currentPageY = touch.pageY), - (touchRecord.currentTimeStamp = timestampForTouch(touch)), - (touchHistory.mostRecentTimeStamp = timestampForTouch(touch))) - : console.warn( - "Cannot record touch end without a touch start.\nTouch End: %s\n", - "Touch Bank: %s", - printTouch(touch), - printTouchBank() - ); -} -function printTouch(touch) { - return JSON.stringify({ - identifier: touch.identifier, - pageX: touch.pageX, - pageY: touch.pageY, - timestamp: timestampForTouch(touch) - }); -} -function printTouchBank() { - var printed = JSON.stringify(touchBank.slice(0, 20)); - 20 < touchBank.length && - (printed += " (original size: " + touchBank.length + ")"); - return printed; + touchRecord && + ((touchRecord.touchActive = !1), + (touchRecord.previousPageX = touchRecord.currentPageX), + (touchRecord.previousPageY = touchRecord.currentPageY), + (touchRecord.previousTimeStamp = touchRecord.currentTimeStamp), + (touchRecord.currentPageX = touch.pageX), + (touchRecord.currentPageY = touch.pageY), + (touchRecord.currentTimeStamp = timestampForTouch(touch)), + (touchHistory.mostRecentTimeStamp = timestampForTouch(touch))); } var ResponderTouchHistoryStore = { recordTouchTrack: function(topLevelType, nativeEvent) { @@ -682,13 +656,7 @@ var eventTypes = { "topTouchCancel" === topLevelType ) if (0 <= trackedTouchCount) --trackedTouchCount; - else - return ( - console.warn( - "Ended a touch event which was not counted in `trackedTouchCount`." - ), - null - ); + else return null; ResponderTouchHistoryStore.recordTouchTrack(topLevelType, nativeEvent); if ( targetInst && @@ -1160,7 +1128,8 @@ var hasSymbol = "function" === typeof Symbol && Symbol.for, ? Symbol.for("react.suspense_list") : 60120, REACT_MEMO_TYPE = hasSymbol ? Symbol.for("react.memo") : 60115, - REACT_LAZY_TYPE = hasSymbol ? Symbol.for("react.lazy") : 60116; + REACT_LAZY_TYPE = hasSymbol ? Symbol.for("react.lazy") : 60116, + REACT_CHUNK_TYPE = hasSymbol ? Symbol.for("react.chunk") : 60121; hasSymbol && Symbol.for("react.fundamental"); hasSymbol && Symbol.for("react.responder"); hasSymbol && Symbol.for("react.scope"); @@ -1225,6 +1194,8 @@ function getComponentName(type) { ); case REACT_MEMO_TYPE: return getComponentName(type.type); + case REACT_CHUNK_TYPE: + return getComponentName(type.render); case REACT_LAZY_TYPE: if ((type = 1 === type._status ? type._result : null)) return getComponentName(type); @@ -2038,237 +2009,195 @@ function readContext(context, observedBits) { return context._currentValue; } var hasForceUpdate = !1; -function createUpdateQueue(baseState) { - return { - baseState: baseState, - firstUpdate: null, - lastUpdate: null, - firstCapturedUpdate: null, - lastCapturedUpdate: null, - firstEffect: null, - lastEffect: null, - firstCapturedEffect: null, - lastCapturedEffect: null +function initializeUpdateQueue(fiber) { + fiber.updateQueue = { + baseState: fiber.memoizedState, + baseQueue: null, + shared: { pending: null }, + effects: null }; } -function cloneUpdateQueue(currentQueue) { - return { - baseState: currentQueue.baseState, - firstUpdate: currentQueue.firstUpdate, - lastUpdate: currentQueue.lastUpdate, - firstCapturedUpdate: null, - lastCapturedUpdate: null, - firstEffect: null, - lastEffect: null, - firstCapturedEffect: null, - lastCapturedEffect: null - }; +function cloneUpdateQueue(current, workInProgress) { + current = current.updateQueue; + workInProgress.updateQueue === current && + (workInProgress.updateQueue = { + baseState: current.baseState, + baseQueue: current.baseQueue, + shared: current.shared, + effects: current.effects + }); } function createUpdate(expirationTime, suspenseConfig) { - return { + expirationTime = { expirationTime: expirationTime, suspenseConfig: suspenseConfig, tag: 0, payload: null, callback: null, - next: null, - nextEffect: null + next: null }; -} -function appendUpdateToQueue(queue, update) { - null === queue.lastUpdate - ? (queue.firstUpdate = queue.lastUpdate = update) - : ((queue.lastUpdate.next = update), (queue.lastUpdate = update)); + return (expirationTime.next = expirationTime); } function enqueueUpdate(fiber, update) { - var alternate = fiber.alternate; - if (null === alternate) { - var queue1 = fiber.updateQueue; - var queue2 = null; - null === queue1 && - (queue1 = fiber.updateQueue = createUpdateQueue(fiber.memoizedState)); - } else - (queue1 = fiber.updateQueue), - (queue2 = alternate.updateQueue), - null === queue1 - ? null === queue2 - ? ((queue1 = fiber.updateQueue = createUpdateQueue( - fiber.memoizedState - )), - (queue2 = alternate.updateQueue = createUpdateQueue( - alternate.memoizedState - ))) - : (queue1 = fiber.updateQueue = cloneUpdateQueue(queue2)) - : null === queue2 && - (queue2 = alternate.updateQueue = cloneUpdateQueue(queue1)); - null === queue2 || queue1 === queue2 - ? appendUpdateToQueue(queue1, update) - : null === queue1.lastUpdate || null === queue2.lastUpdate - ? (appendUpdateToQueue(queue1, update), - appendUpdateToQueue(queue2, update)) - : (appendUpdateToQueue(queue1, update), (queue2.lastUpdate = update)); + fiber = fiber.updateQueue; + if (null !== fiber) { + fiber = fiber.shared; + var pending = fiber.pending; + null === pending + ? (update.next = update) + : ((update.next = pending.next), (pending.next = update)); + fiber.pending = update; + } } function enqueueCapturedUpdate(workInProgress, update) { - var workInProgressQueue = workInProgress.updateQueue; - workInProgressQueue = - null === workInProgressQueue - ? (workInProgress.updateQueue = createUpdateQueue( - workInProgress.memoizedState - )) - : ensureWorkInProgressQueueIsAClone(workInProgress, workInProgressQueue); - null === workInProgressQueue.lastCapturedUpdate - ? (workInProgressQueue.firstCapturedUpdate = workInProgressQueue.lastCapturedUpdate = update) - : ((workInProgressQueue.lastCapturedUpdate.next = update), - (workInProgressQueue.lastCapturedUpdate = update)); -} -function ensureWorkInProgressQueueIsAClone(workInProgress, queue) { var current = workInProgress.alternate; - null !== current && - queue === current.updateQueue && - (queue = workInProgress.updateQueue = cloneUpdateQueue(queue)); - return queue; -} -function getStateFromUpdate( - workInProgress, - queue, - update, - prevState, - nextProps, - instance -) { - switch (update.tag) { - case 1: - return ( - (workInProgress = update.payload), - "function" === typeof workInProgress - ? workInProgress.call(instance, prevState, nextProps) - : workInProgress - ); - case 3: - workInProgress.effectTag = (workInProgress.effectTag & -4097) | 64; - case 0: - workInProgress = update.payload; - nextProps = - "function" === typeof workInProgress - ? workInProgress.call(instance, prevState, nextProps) - : workInProgress; - if (null === nextProps || void 0 === nextProps) break; - return Object.assign({}, prevState, nextProps); - case 2: - hasForceUpdate = !0; - } - return prevState; + null !== current && cloneUpdateQueue(current, workInProgress); + workInProgress = workInProgress.updateQueue; + current = workInProgress.baseQueue; + null === current + ? ((workInProgress.baseQueue = update.next = update), + (update.next = update)) + : ((update.next = current.next), (current.next = update)); } function processUpdateQueue( - workInProgress, - queue, + workInProgress$jscomp$0, props, instance, renderExpirationTime ) { + var queue = workInProgress$jscomp$0.updateQueue; hasForceUpdate = !1; - queue = ensureWorkInProgressQueueIsAClone(workInProgress, queue); - for ( - var newBaseState = queue.baseState, - newFirstUpdate = null, - newExpirationTime = 0, - update = queue.firstUpdate, - resultState = newBaseState; - null !== update; - - ) { - var updateExpirationTime = update.expirationTime; - updateExpirationTime < renderExpirationTime - ? (null === newFirstUpdate && - ((newFirstUpdate = update), (newBaseState = resultState)), - newExpirationTime < updateExpirationTime && - (newExpirationTime = updateExpirationTime)) - : (markRenderEventTimeAndConfig( - updateExpirationTime, - update.suspenseConfig - ), - (resultState = getStateFromUpdate( - workInProgress, - queue, - update, - resultState, - props, - instance - )), - null !== update.callback && - ((workInProgress.effectTag |= 32), - (update.nextEffect = null), - null === queue.lastEffect - ? (queue.firstEffect = queue.lastEffect = update) - : ((queue.lastEffect.nextEffect = update), - (queue.lastEffect = update)))); - update = update.next; + var baseQueue = queue.baseQueue, + pendingQueue = queue.shared.pending; + if (null !== pendingQueue) { + if (null !== baseQueue) { + var baseFirst = baseQueue.next; + baseQueue.next = pendingQueue.next; + pendingQueue.next = baseFirst; + } + baseQueue = pendingQueue; + queue.shared.pending = null; + baseFirst = workInProgress$jscomp$0.alternate; + null !== baseFirst && + ((baseFirst = baseFirst.updateQueue), + null !== baseFirst && (baseFirst.baseQueue = pendingQueue)); } - updateExpirationTime = null; - for (update = queue.firstCapturedUpdate; null !== update; ) { - var _updateExpirationTime = update.expirationTime; - _updateExpirationTime < renderExpirationTime - ? (null === updateExpirationTime && - ((updateExpirationTime = update), - null === newFirstUpdate && (newBaseState = resultState)), - newExpirationTime < _updateExpirationTime && - (newExpirationTime = _updateExpirationTime)) - : ((resultState = getStateFromUpdate( - workInProgress, - queue, - update, - resultState, - props, - instance - )), - null !== update.callback && - ((workInProgress.effectTag |= 32), - (update.nextEffect = null), - null === queue.lastCapturedEffect - ? (queue.firstCapturedEffect = queue.lastCapturedEffect = update) - : ((queue.lastCapturedEffect.nextEffect = update), - (queue.lastCapturedEffect = update)))); - update = update.next; + if (null !== baseQueue) { + baseFirst = baseQueue.next; + var newState = queue.baseState, + newExpirationTime = 0, + newBaseState = null, + newBaseQueueFirst = null, + newBaseQueueLast = null; + if (null !== baseFirst) { + var update = baseFirst; + do { + pendingQueue = update.expirationTime; + if (pendingQueue < renderExpirationTime) { + var clone = { + expirationTime: update.expirationTime, + suspenseConfig: update.suspenseConfig, + tag: update.tag, + payload: update.payload, + callback: update.callback, + next: null + }; + null === newBaseQueueLast + ? ((newBaseQueueFirst = newBaseQueueLast = clone), + (newBaseState = newState)) + : (newBaseQueueLast = newBaseQueueLast.next = clone); + pendingQueue > newExpirationTime && + (newExpirationTime = pendingQueue); + } else { + null !== newBaseQueueLast && + (newBaseQueueLast = newBaseQueueLast.next = { + expirationTime: 1073741823, + suspenseConfig: update.suspenseConfig, + tag: update.tag, + payload: update.payload, + callback: update.callback, + next: null + }); + markRenderEventTimeAndConfig(pendingQueue, update.suspenseConfig); + a: { + var workInProgress = workInProgress$jscomp$0, + update$jscomp$0 = update; + pendingQueue = props; + clone = instance; + switch (update$jscomp$0.tag) { + case 1: + workInProgress = update$jscomp$0.payload; + if ("function" === typeof workInProgress) { + newState = workInProgress.call(clone, newState, pendingQueue); + break a; + } + newState = workInProgress; + break a; + case 3: + workInProgress.effectTag = + (workInProgress.effectTag & -4097) | 64; + case 0: + workInProgress = update$jscomp$0.payload; + pendingQueue = + "function" === typeof workInProgress + ? workInProgress.call(clone, newState, pendingQueue) + : workInProgress; + if (null === pendingQueue || void 0 === pendingQueue) break a; + newState = Object.assign({}, newState, pendingQueue); + break a; + case 2: + hasForceUpdate = !0; + } + } + null !== update.callback && + ((workInProgress$jscomp$0.effectTag |= 32), + (pendingQueue = queue.effects), + null === pendingQueue + ? (queue.effects = [update]) + : pendingQueue.push(update)); + } + update = update.next; + if (null === update || update === baseFirst) + if (((pendingQueue = queue.shared.pending), null === pendingQueue)) + break; + else + (update = baseQueue.next = pendingQueue.next), + (pendingQueue.next = baseFirst), + (queue.baseQueue = baseQueue = pendingQueue), + (queue.shared.pending = null); + } while (1); + } + null === newBaseQueueLast + ? (newBaseState = newState) + : (newBaseQueueLast.next = newBaseQueueFirst); + queue.baseState = newBaseState; + queue.baseQueue = newBaseQueueLast; + markUnprocessedUpdateTime(newExpirationTime); + workInProgress$jscomp$0.expirationTime = newExpirationTime; + workInProgress$jscomp$0.memoizedState = newState; } - null === newFirstUpdate && (queue.lastUpdate = null); - null === updateExpirationTime - ? (queue.lastCapturedUpdate = null) - : (workInProgress.effectTag |= 32); - null === newFirstUpdate && - null === updateExpirationTime && - (newBaseState = resultState); - queue.baseState = newBaseState; - queue.firstUpdate = newFirstUpdate; - queue.firstCapturedUpdate = updateExpirationTime; - markUnprocessedUpdateTime(newExpirationTime); - workInProgress.expirationTime = newExpirationTime; - workInProgress.memoizedState = resultState; } function commitUpdateQueue(finishedWork, finishedQueue, instance) { - null !== finishedQueue.firstCapturedUpdate && - (null !== finishedQueue.lastUpdate && - ((finishedQueue.lastUpdate.next = finishedQueue.firstCapturedUpdate), - (finishedQueue.lastUpdate = finishedQueue.lastCapturedUpdate)), - (finishedQueue.firstCapturedUpdate = finishedQueue.lastCapturedUpdate = null)); - commitUpdateEffects(finishedQueue.firstEffect, instance); - finishedQueue.firstEffect = finishedQueue.lastEffect = null; - commitUpdateEffects(finishedQueue.firstCapturedEffect, instance); - finishedQueue.firstCapturedEffect = finishedQueue.lastCapturedEffect = null; -} -function commitUpdateEffects(effect, instance) { - for (; null !== effect; ) { - var callback = effect.callback; - if (null !== callback) { - effect.callback = null; - if ("function" !== typeof callback) - throw Error( - "Invalid argument passed as callback. Expected a function. Instead received: " + - callback - ); - callback.call(instance); + finishedWork = finishedQueue.effects; + finishedQueue.effects = null; + if (null !== finishedWork) + for ( + finishedQueue = 0; + finishedQueue < finishedWork.length; + finishedQueue++ + ) { + var effect = finishedWork[finishedQueue], + callback = effect.callback; + if (null !== callback) { + effect.callback = null; + if ("function" !== typeof callback) + throw Error( + "Invalid argument passed as callback. Expected a function. Instead received: " + + callback + ); + callback.call(instance); + } } - effect = effect.nextEffect; - } } var ReactCurrentBatchConfig = ReactSharedInternals.ReactCurrentBatchConfig, emptyRefsObject = new React.Component().refs; @@ -2285,10 +2214,8 @@ function applyDerivedStateFromProps( ? ctor : Object.assign({}, ctor, getDerivedStateFromProps); workInProgress.memoizedState = getDerivedStateFromProps; - nextProps = workInProgress.updateQueue; - null !== nextProps && - 0 === workInProgress.expirationTime && - (nextProps.baseState = getDerivedStateFromProps); + 0 === workInProgress.expirationTime && + (workInProgress.updateQueue.baseState = getDerivedStateFromProps); } var classComponentUpdater = { isMounted: function(component) { @@ -2403,6 +2330,7 @@ function mountClassInstance( instance.props = newProps; instance.state = workInProgress.memoizedState; instance.refs = emptyRefsObject; + initializeUpdateQueue(workInProgress); var contextType = ctor.contextType; "object" === typeof contextType && null !== contextType ? (instance.context = readContext(contextType)) @@ -2410,16 +2338,8 @@ function mountClassInstance( ? previousContext : contextStackCursor.current), (instance.context = getMaskedContext(workInProgress, contextType))); - contextType = workInProgress.updateQueue; - null !== contextType && - (processUpdateQueue( - workInProgress, - contextType, - newProps, - instance, - renderExpirationTime - ), - (instance.state = workInProgress.memoizedState)); + processUpdateQueue(workInProgress, newProps, instance, renderExpirationTime); + instance.state = workInProgress.memoizedState; contextType = ctor.getDerivedStateFromProps; "function" === typeof contextType && (applyDerivedStateFromProps(workInProgress, ctor, contextType, newProps), @@ -2435,16 +2355,13 @@ function mountClassInstance( instance.UNSAFE_componentWillMount(), ctor !== instance.state && classComponentUpdater.enqueueReplaceState(instance, instance.state, null), - (contextType = workInProgress.updateQueue), - null !== contextType && - (processUpdateQueue( - workInProgress, - contextType, - newProps, - instance, - renderExpirationTime - ), - (instance.state = workInProgress.memoizedState))); + processUpdateQueue( + workInProgress, + newProps, + instance, + renderExpirationTime + ), + (instance.state = workInProgress.memoizedState)); "function" === typeof instance.componentDidMount && (workInProgress.effectTag |= 4); } @@ -3006,39 +2923,50 @@ function ChildReconciler(shouldTrackSideEffects) { null !== isUnkeyedTopLevelFragment; ) { - if (isUnkeyedTopLevelFragment.key === isObject) - if ( - 7 === isUnkeyedTopLevelFragment.tag - ? newChild.type === REACT_FRAGMENT_TYPE - : isUnkeyedTopLevelFragment.elementType === newChild.type - ) { - deleteRemainingChildren( - returnFiber, - isUnkeyedTopLevelFragment.sibling - ); - currentFirstChild = useFiber( - isUnkeyedTopLevelFragment, - newChild.type === REACT_FRAGMENT_TYPE - ? newChild.props.children - : newChild.props, - expirationTime - ); - currentFirstChild.ref = coerceRef( - returnFiber, - isUnkeyedTopLevelFragment, - newChild - ); - currentFirstChild.return = returnFiber; - returnFiber = currentFirstChild; - break a; - } else { - deleteRemainingChildren( - returnFiber, - isUnkeyedTopLevelFragment - ); - break; + if (isUnkeyedTopLevelFragment.key === isObject) { + switch (isUnkeyedTopLevelFragment.tag) { + case 7: + if (newChild.type === REACT_FRAGMENT_TYPE) { + deleteRemainingChildren( + returnFiber, + isUnkeyedTopLevelFragment.sibling + ); + currentFirstChild = useFiber( + isUnkeyedTopLevelFragment, + newChild.props.children, + expirationTime + ); + currentFirstChild.return = returnFiber; + returnFiber = currentFirstChild; + break a; + } + break; + default: + if ( + isUnkeyedTopLevelFragment.elementType === newChild.type + ) { + deleteRemainingChildren( + returnFiber, + isUnkeyedTopLevelFragment.sibling + ); + currentFirstChild = useFiber( + isUnkeyedTopLevelFragment, + newChild.props, + expirationTime + ); + currentFirstChild.ref = coerceRef( + returnFiber, + isUnkeyedTopLevelFragment, + newChild + ); + currentFirstChild.return = returnFiber; + returnFiber = currentFirstChild; + break a; + } } - else deleteChild(returnFiber, isUnkeyedTopLevelFragment); + deleteRemainingChildren(returnFiber, isUnkeyedTopLevelFragment); + break; + } else deleteChild(returnFiber, isUnkeyedTopLevelFragment); isUnkeyedTopLevelFragment = isUnkeyedTopLevelFragment.sibling; } newChild.type === REACT_FRAGMENT_TYPE @@ -3236,7 +3164,7 @@ function findFirstSuspended(row) { } return null; } -function createResponderListener(responder, props) { +function createDeprecatedResponderListener(responder, props) { return { responder: responder, props: props }; } var ReactCurrentDispatcher$1 = ReactSharedInternals.ReactCurrentDispatcher, @@ -3244,13 +3172,7 @@ var ReactCurrentDispatcher$1 = ReactSharedInternals.ReactCurrentDispatcher, renderExpirationTime$1 = 0, currentlyRenderingFiber$1 = null, currentHook = null, - nextCurrentHook = null, - firstWorkInProgressHook = null, workInProgressHook = null, - nextWorkInProgressHook = null, - remainingExpirationTime = 0, - componentUpdateQueue = null, - sideEffectTag = 0, didScheduleRenderPhaseUpdate = !1, renderPhaseUpdates = null, numberOfReRenders = 0; @@ -3270,53 +3192,45 @@ function renderWithHooks( workInProgress, Component, props, - refOrContext, + secondArg, nextRenderExpirationTime ) { renderExpirationTime$1 = nextRenderExpirationTime; currentlyRenderingFiber$1 = workInProgress; - nextCurrentHook = null !== current ? current.memoizedState : null; + workInProgress.memoizedState = null; + workInProgress.updateQueue = null; + workInProgress.expirationTime = 0; ReactCurrentDispatcher$1.current = - null === nextCurrentHook ? HooksDispatcherOnMount : HooksDispatcherOnUpdate; - workInProgress = Component(props, refOrContext); + null === current || null === current.memoizedState + ? HooksDispatcherOnMount + : HooksDispatcherOnUpdate; + current = Component(props, secondArg); if (didScheduleRenderPhaseUpdate) { do (didScheduleRenderPhaseUpdate = !1), (numberOfReRenders += 1), - (nextCurrentHook = null !== current ? current.memoizedState : null), - (nextWorkInProgressHook = firstWorkInProgressHook), - (componentUpdateQueue = workInProgressHook = currentHook = null), + (workInProgressHook = currentHook = null), + (workInProgress.updateQueue = null), (ReactCurrentDispatcher$1.current = HooksDispatcherOnUpdate), - (workInProgress = Component(props, refOrContext)); + (current = Component(props, secondArg)); while (didScheduleRenderPhaseUpdate); renderPhaseUpdates = null; numberOfReRenders = 0; } ReactCurrentDispatcher$1.current = ContextOnlyDispatcher; - current = currentlyRenderingFiber$1; - current.memoizedState = firstWorkInProgressHook; - current.expirationTime = remainingExpirationTime; - current.updateQueue = componentUpdateQueue; - current.effectTag |= sideEffectTag; - current = null !== currentHook && null !== currentHook.next; + workInProgress = null !== currentHook && null !== currentHook.next; renderExpirationTime$1 = 0; - nextWorkInProgressHook = workInProgressHook = firstWorkInProgressHook = nextCurrentHook = currentHook = currentlyRenderingFiber$1 = null; - remainingExpirationTime = 0; - componentUpdateQueue = null; - sideEffectTag = 0; - if (current) + workInProgressHook = currentHook = currentlyRenderingFiber$1 = null; + if (workInProgress) throw Error( "Rendered fewer hooks than expected. This may be caused by an accidental early return statement." ); - return workInProgress; + return current; } function resetHooks() { ReactCurrentDispatcher$1.current = ContextOnlyDispatcher; renderExpirationTime$1 = 0; - nextWorkInProgressHook = workInProgressHook = firstWorkInProgressHook = nextCurrentHook = currentHook = currentlyRenderingFiber$1 = null; - remainingExpirationTime = 0; - componentUpdateQueue = null; - sideEffectTag = 0; + workInProgressHook = currentHook = currentlyRenderingFiber$1 = null; didScheduleRenderPhaseUpdate = !1; renderPhaseUpdates = null; numberOfReRenders = 0; @@ -3325,37 +3239,42 @@ function mountWorkInProgressHook() { var hook = { memoizedState: null, baseState: null, + baseQueue: null, queue: null, - baseUpdate: null, next: null }; null === workInProgressHook - ? (firstWorkInProgressHook = workInProgressHook = hook) + ? (currentlyRenderingFiber$1.memoizedState = workInProgressHook = hook) : (workInProgressHook = workInProgressHook.next = hook); return workInProgressHook; } function updateWorkInProgressHook() { + if (null === currentHook) { + var nextCurrentHook = currentlyRenderingFiber$1.alternate; + nextCurrentHook = + null !== nextCurrentHook ? nextCurrentHook.memoizedState : null; + } else nextCurrentHook = currentHook.next; + var nextWorkInProgressHook = + null === workInProgressHook + ? currentlyRenderingFiber$1.memoizedState + : workInProgressHook.next; if (null !== nextWorkInProgressHook) (workInProgressHook = nextWorkInProgressHook), - (nextWorkInProgressHook = workInProgressHook.next), - (currentHook = nextCurrentHook), - (nextCurrentHook = null !== currentHook ? currentHook.next : null); + (currentHook = nextCurrentHook); else { if (null === nextCurrentHook) throw Error("Rendered more hooks than during the previous render."); currentHook = nextCurrentHook; - var newHook = { + nextCurrentHook = { memoizedState: currentHook.memoizedState, baseState: currentHook.baseState, + baseQueue: currentHook.baseQueue, queue: currentHook.queue, - baseUpdate: currentHook.baseUpdate, next: null }; - workInProgressHook = - null === workInProgressHook - ? (firstWorkInProgressHook = newHook) - : (workInProgressHook.next = newHook); - nextCurrentHook = currentHook.next; + null === workInProgressHook + ? (currentlyRenderingFiber$1.memoizedState = workInProgressHook = nextCurrentHook) + : (workInProgressHook = workInProgressHook.next = nextCurrentHook); } return workInProgressHook; } @@ -3383,51 +3302,75 @@ function updateReducer(reducer) { while (null !== firstRenderPhaseUpdate); is$1(newState, hook.memoizedState) || (didReceiveUpdate = !0); hook.memoizedState = newState; - hook.baseUpdate === queue.last && (hook.baseState = newState); + null === hook.baseQueue && (hook.baseState = newState); queue.lastRenderedState = newState; return [newState, _dispatch]; } } return [hook.memoizedState, _dispatch]; } - _dispatch = queue.last; - var baseUpdate = hook.baseUpdate; - newState = hook.baseState; - null !== baseUpdate - ? (null !== _dispatch && (_dispatch.next = null), - (_dispatch = baseUpdate.next)) - : (_dispatch = null !== _dispatch ? _dispatch.next : null); + newState = currentHook; + _dispatch = newState.baseQueue; + firstRenderPhaseUpdate = queue.pending; + if (null !== firstRenderPhaseUpdate) { + if (null !== _dispatch) { + var baseFirst = _dispatch.next; + _dispatch.next = firstRenderPhaseUpdate.next; + firstRenderPhaseUpdate.next = baseFirst; + } + newState.baseQueue = _dispatch = firstRenderPhaseUpdate; + queue.pending = null; + } if (null !== _dispatch) { - var newBaseUpdate = (firstRenderPhaseUpdate = null), - _update = _dispatch, - didSkip = !1; + _dispatch = _dispatch.next; + newState = newState.baseState; + var newBaseQueueLast = (baseFirst = firstRenderPhaseUpdate = null), + _update = _dispatch; do { var updateExpirationTime = _update.expirationTime; - updateExpirationTime < renderExpirationTime$1 - ? (didSkip || - ((didSkip = !0), - (newBaseUpdate = baseUpdate), - (firstRenderPhaseUpdate = newState)), - updateExpirationTime > remainingExpirationTime && - ((remainingExpirationTime = updateExpirationTime), - markUnprocessedUpdateTime(remainingExpirationTime))) - : (markRenderEventTimeAndConfig( + if (updateExpirationTime < renderExpirationTime$1) { + var clone = { + expirationTime: _update.expirationTime, + suspenseConfig: _update.suspenseConfig, + action: _update.action, + eagerReducer: _update.eagerReducer, + eagerState: _update.eagerState, + next: null + }; + null === newBaseQueueLast + ? ((baseFirst = newBaseQueueLast = clone), + (firstRenderPhaseUpdate = newState)) + : (newBaseQueueLast = newBaseQueueLast.next = clone); + updateExpirationTime > currentlyRenderingFiber$1.expirationTime && + ((currentlyRenderingFiber$1.expirationTime = updateExpirationTime), + markUnprocessedUpdateTime(updateExpirationTime)); + } else + null !== newBaseQueueLast && + (newBaseQueueLast = newBaseQueueLast.next = { + expirationTime: 1073741823, + suspenseConfig: _update.suspenseConfig, + action: _update.action, + eagerReducer: _update.eagerReducer, + eagerState: _update.eagerState, + next: null + }), + markRenderEventTimeAndConfig( updateExpirationTime, _update.suspenseConfig ), (newState = _update.eagerReducer === reducer ? _update.eagerState - : reducer(newState, _update.action))); - baseUpdate = _update; + : reducer(newState, _update.action)); _update = _update.next; } while (null !== _update && _update !== _dispatch); - didSkip || - ((newBaseUpdate = baseUpdate), (firstRenderPhaseUpdate = newState)); + null === newBaseQueueLast + ? (firstRenderPhaseUpdate = newState) + : (newBaseQueueLast.next = baseFirst); is$1(newState, hook.memoizedState) || (didReceiveUpdate = !0); hook.memoizedState = newState; - hook.baseUpdate = newBaseUpdate; hook.baseState = firstRenderPhaseUpdate; + hook.baseQueue = newBaseQueueLast; queue.lastRenderedState = newState; } return [hook.memoizedState, queue.dispatch]; @@ -3437,7 +3380,7 @@ function mountState(initialState) { "function" === typeof initialState && (initialState = initialState()); hook.memoizedState = hook.baseState = initialState; initialState = hook.queue = { - last: null, + pending: null, dispatch: null, lastRenderedReducer: basicStateReducer, lastRenderedState: initialState @@ -3454,21 +3397,23 @@ function updateState(initialState) { } function pushEffect(tag, create, destroy, deps) { tag = { tag: tag, create: create, destroy: destroy, deps: deps, next: null }; - null === componentUpdateQueue - ? ((componentUpdateQueue = { lastEffect: null }), - (componentUpdateQueue.lastEffect = tag.next = tag)) - : ((create = componentUpdateQueue.lastEffect), - null === create - ? (componentUpdateQueue.lastEffect = tag.next = tag) - : ((destroy = create.next), - (create.next = tag), - (tag.next = destroy), - (componentUpdateQueue.lastEffect = tag))); + create = currentlyRenderingFiber$1.updateQueue; + null === create + ? ((create = { lastEffect: null }), + (currentlyRenderingFiber$1.updateQueue = create), + (create.lastEffect = tag.next = tag)) + : ((destroy = create.lastEffect), + null === destroy + ? (create.lastEffect = tag.next = tag) + : ((deps = destroy.next), + (destroy.next = tag), + (tag.next = deps), + (create.lastEffect = tag))); return tag; } function mountEffectImpl(fiberEffectTag, hookEffectTag, create, deps) { var hook = mountWorkInProgressHook(); - sideEffectTag |= fiberEffectTag; + currentlyRenderingFiber$1.effectTag |= fiberEffectTag; hook.memoizedState = pushEffect( hookEffectTag, create, @@ -3488,7 +3433,7 @@ function updateEffectImpl(fiberEffectTag, hookEffectTag, create, deps) { return; } } - sideEffectTag |= fiberEffectTag; + currentlyRenderingFiber$1.effectTag |= fiberEffectTag; hook.memoizedState = pushEffect(hookEffectTag, create, destroy, deps); } function mountEffect(create, deps) { @@ -3536,6 +3481,21 @@ function updateCallback(callback, deps) { hook.memoizedState = [callback, deps]; return callback; } +function startTransition(setPending, config, callback) { + var priorityLevel = getCurrentPriorityLevel(); + runWithPriority(98 > priorityLevel ? 98 : priorityLevel, function() { + setPending(!0); + }); + runWithPriority(97 < priorityLevel ? 97 : priorityLevel, function() { + var previousConfig = ReactCurrentBatchConfig$1.suspense; + ReactCurrentBatchConfig$1.suspense = void 0 === config ? null : config; + try { + setPending(!1), callback(); + } finally { + ReactCurrentBatchConfig$1.suspense = previousConfig; + } + }); +} function dispatchAction(fiber, queue, action) { if (!(25 > numberOfReRenders)) throw Error( @@ -3577,14 +3537,11 @@ function dispatchAction(fiber, queue, action) { eagerState: null, next: null }; - var last = queue.last; - if (null === last) suspenseConfig.next = suspenseConfig; - else { - var first = last.next; - null !== first && (suspenseConfig.next = first); - last.next = suspenseConfig; - } - queue.last = suspenseConfig; + var pending = queue.pending; + null === pending + ? (suspenseConfig.next = suspenseConfig) + : ((suspenseConfig.next = pending.next), (pending.next = suspenseConfig)); + queue.pending = suspenseConfig; if ( 0 === fiber.expirationTime && (null === alternate || 0 === alternate.expirationTime) && @@ -3647,7 +3604,7 @@ var ContextOnlyDispatcher = { initialArg = void 0 !== init ? init(initialArg) : initialArg; hook.memoizedState = hook.baseState = initialArg; reducer = hook.queue = { - last: null, + pending: null, dispatch: null, lastRenderedReducer: reducer, lastRenderedState: initialArg @@ -3666,23 +3623,21 @@ var ContextOnlyDispatcher = { }, useState: mountState, useDebugValue: mountDebugValue, - useResponder: createResponderListener, + useResponder: createDeprecatedResponderListener, useDeferredValue: function(value, config) { var _mountState = mountState(value), prevValue = _mountState[0], setValue = _mountState[1]; mountEffect( function() { - Scheduler.unstable_next(function() { - var previousConfig = ReactCurrentBatchConfig$1.suspense; - ReactCurrentBatchConfig$1.suspense = - void 0 === config ? null : config; - try { - setValue(value); - } finally { - ReactCurrentBatchConfig$1.suspense = previousConfig; - } - }); + var previousConfig = ReactCurrentBatchConfig$1.suspense; + ReactCurrentBatchConfig$1.suspense = + void 0 === config ? null : config; + try { + setValue(value); + } finally { + ReactCurrentBatchConfig$1.suspense = previousConfig; + } }, [value, config] ); @@ -3690,25 +3645,13 @@ var ContextOnlyDispatcher = { }, useTransition: function(config) { var _mountState2 = mountState(!1), - isPending = _mountState2[0], - setPending = _mountState2[1]; + isPending = _mountState2[0]; + _mountState2 = _mountState2[1]; return [ - mountCallback( - function(callback) { - setPending(!0); - Scheduler.unstable_next(function() { - var previousConfig = ReactCurrentBatchConfig$1.suspense; - ReactCurrentBatchConfig$1.suspense = - void 0 === config ? null : config; - try { - setPending(!1), callback(); - } finally { - ReactCurrentBatchConfig$1.suspense = previousConfig; - } - }); - }, - [config, isPending] - ), + mountCallback(startTransition.bind(null, _mountState2, config), [ + _mountState2, + config + ]), isPending ]; } @@ -3750,23 +3693,21 @@ var ContextOnlyDispatcher = { }, useState: updateState, useDebugValue: mountDebugValue, - useResponder: createResponderListener, + useResponder: createDeprecatedResponderListener, useDeferredValue: function(value, config) { var _updateState = updateState(value), prevValue = _updateState[0], setValue = _updateState[1]; updateEffect( function() { - Scheduler.unstable_next(function() { - var previousConfig = ReactCurrentBatchConfig$1.suspense; - ReactCurrentBatchConfig$1.suspense = - void 0 === config ? null : config; - try { - setValue(value); - } finally { - ReactCurrentBatchConfig$1.suspense = previousConfig; - } - }); + var previousConfig = ReactCurrentBatchConfig$1.suspense; + ReactCurrentBatchConfig$1.suspense = + void 0 === config ? null : config; + try { + setValue(value); + } finally { + ReactCurrentBatchConfig$1.suspense = previousConfig; + } }, [value, config] ); @@ -3774,25 +3715,13 @@ var ContextOnlyDispatcher = { }, useTransition: function(config) { var _updateState2 = updateState(!1), - isPending = _updateState2[0], - setPending = _updateState2[1]; + isPending = _updateState2[0]; + _updateState2 = _updateState2[1]; return [ - updateCallback( - function(callback) { - setPending(!0); - Scheduler.unstable_next(function() { - var previousConfig = ReactCurrentBatchConfig$1.suspense; - ReactCurrentBatchConfig$1.suspense = - void 0 === config ? null : config; - try { - setPending(!1), callback(); - } finally { - ReactCurrentBatchConfig$1.suspense = previousConfig; - } - }); - }, - [config, isPending] - ), + updateCallback(startTransition.bind(null, _updateState2, config), [ + _updateState2, + config + ]), isPending ]; } @@ -4117,17 +4046,14 @@ function updateClassComponent( )); hasForceUpdate = !1; var oldState = workInProgress.memoizedState; - oldContext = instance.state = oldState; - var updateQueue = workInProgress.updateQueue; - null !== updateQueue && - (processUpdateQueue( - workInProgress, - updateQueue, - nextProps, - instance, - renderExpirationTime - ), - (oldContext = workInProgress.memoizedState)); + instance.state = oldState; + processUpdateQueue( + workInProgress, + nextProps, + instance, + renderExpirationTime + ); + oldContext = workInProgress.memoizedState; oldProps !== nextProps || oldState !== oldContext || didPerformWorkStackCursor.current || @@ -4173,6 +4099,7 @@ function updateClassComponent( (nextProps = !1)); } else (instance = workInProgress.stateNode), + cloneUpdateQueue(current$$1, workInProgress), (oldProps = workInProgress.memoizedProps), (instance.props = workInProgress.type === workInProgress.elementType @@ -4201,17 +4128,14 @@ function updateClassComponent( )), (hasForceUpdate = !1), (oldContext = workInProgress.memoizedState), - (oldState = instance.state = oldContext), - (updateQueue = workInProgress.updateQueue), - null !== updateQueue && - (processUpdateQueue( - workInProgress, - updateQueue, - nextProps, - instance, - renderExpirationTime - ), - (oldState = workInProgress.memoizedState)), + (instance.state = oldContext), + processUpdateQueue( + workInProgress, + nextProps, + instance, + renderExpirationTime + ), + (oldState = workInProgress.memoizedState), oldProps !== nextProps || oldContext !== oldState || didPerformWorkStackCursor.current || @@ -4531,6 +4455,7 @@ function initSuspenseListRenderState( ? (workInProgress.memoizedState = { isBackwards: isBackwards, rendering: null, + renderingStartTime: 0, last: lastContentRow, tail: tail, tailExpiration: 0, @@ -4539,6 +4464,7 @@ function initSuspenseListRenderState( }) : ((renderState.isBackwards = isBackwards), (renderState.rendering = null), + (renderState.renderingStartTime = 0), (renderState.last = lastContentRow), (renderState.tail = tail), (renderState.tailExpiration = 0), @@ -4750,24 +4676,32 @@ function completeWork(current, workInProgress, renderExpirationTime$jscomp$0) { var newProps = workInProgress.pendingProps; switch (workInProgress.tag) { case 2: - break; case 16: - break; case 15: case 0: - break; + case 11: + case 7: + case 8: + case 12: + case 9: + case 14: + return null; case 1: - isContextProvider(workInProgress.type) && popContext(workInProgress); - break; + return ( + isContextProvider(workInProgress.type) && popContext(workInProgress), + null + ); case 3: - popHostContainer(workInProgress); - popTopLevelContextObject(workInProgress); - current = workInProgress.stateNode; - current.pendingContext && - ((current.context = current.pendingContext), - (current.pendingContext = null)); - updateHostContainer(workInProgress); - break; + return ( + popHostContainer(workInProgress), + popTopLevelContextObject(workInProgress), + (current = workInProgress.stateNode), + current.pendingContext && + ((current.context = current.pendingContext), + (current.pendingContext = null)), + updateHostContainer(workInProgress), + null + ); case 5: popHostContext(workInProgress); var rootContainerInstance = requiredContext( @@ -4784,7 +4718,14 @@ function completeWork(current, workInProgress, renderExpirationTime$jscomp$0) { ), current.ref !== workInProgress.ref && (workInProgress.effectTag |= 128); - else if (newProps) { + 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." + ); + return null; + } current = requiredContext(contextStackCursor$1.current); var tag = allocateTag(), viewConfig = getViewConfigForType(renderExpirationTime$jscomp$0), @@ -4813,11 +4754,8 @@ function completeWork(current, workInProgress, renderExpirationTime$jscomp$0) { current ) && (workInProgress.effectTag |= 4); null !== workInProgress.ref && (workInProgress.effectTag |= 128); - } else 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." - ); - break; + } + return null; case 6: if (current && null != workInProgress.stateNode) updateHostText$1( @@ -4846,9 +4784,7 @@ function completeWork(current, workInProgress, renderExpirationTime$jscomp$0) { instanceCache.set(rootContainerInstance, workInProgress); workInProgress.stateNode = rootContainerInstance; } - break; - case 11: - break; + return null; case 13: pop(suspenseStackCursor, workInProgress); newProps = workInProgress.memoizedState; @@ -4896,31 +4832,24 @@ function completeWork(current, workInProgress, renderExpirationTime$jscomp$0) { )); } if (newProps || rootContainerInstance) workInProgress.effectTag |= 4; - break; - case 7: - break; - case 8: - break; - case 12: - break; + return null; case 4: - popHostContainer(workInProgress); - updateHostContainer(workInProgress); - break; + return ( + popHostContainer(workInProgress), + updateHostContainer(workInProgress), + null + ); case 10: - popProvider(workInProgress); - break; - case 9: - break; - case 14: - break; + return popProvider(workInProgress), null; case 17: - isContextProvider(workInProgress.type) && popContext(workInProgress); - break; + return ( + isContextProvider(workInProgress.type) && popContext(workInProgress), + null + ); case 19: pop(suspenseStackCursor, workInProgress); newProps = workInProgress.memoizedState; - if (null === newProps) break; + if (null === newProps) return null; rootContainerInstance = 0 !== (workInProgress.effectTag & 64); tag = newProps.rendering; if (null === tag) @@ -5012,13 +4941,15 @@ function completeWork(current, workInProgress, renderExpirationTime$jscomp$0) { null === newProps.tail && "hidden" === newProps.tailMode && !tag.alternate) - ) { - workInProgress = workInProgress.lastEffect = newProps.lastEffect; - null !== workInProgress && (workInProgress.nextEffect = null); - break; - } + ) + return ( + (workInProgress = workInProgress.lastEffect = + newProps.lastEffect), + null !== workInProgress && (workInProgress.nextEffect = null), + null + ); } else - now() > newProps.tailExpiration && + 2 * now() - newProps.renderingStartTime > newProps.tailExpiration && 1 < renderExpirationTime$jscomp$0 && ((workInProgress.effectTag |= 64), (rootContainerInstance = !0), @@ -5036,14 +4967,14 @@ function completeWork(current, workInProgress, renderExpirationTime$jscomp$0) { : (workInProgress.child = tag), (newProps.last = tag)); } - if (null !== newProps.tail) - return ( - 0 === newProps.tailExpiration && + return null !== newProps.tail + ? (0 === newProps.tailExpiration && (newProps.tailExpiration = now() + 500), (current = newProps.tail), (newProps.rendering = current), (newProps.tail = current.sibling), (newProps.lastEffect = workInProgress.lastEffect), + (newProps.renderingStartTime = now()), (current.sibling = null), (newProps = suspenseStackCursor.current), push( @@ -5051,21 +4982,14 @@ function completeWork(current, workInProgress, renderExpirationTime$jscomp$0) { rootContainerInstance ? (newProps & 1) | 2 : newProps & 1, workInProgress ), - current - ); - break; - case 20: - break; - case 21: - break; - default: - throw Error( - "Unknown unit of work tag (" + - workInProgress.tag + - "). This error is likely caused by a bug in React. Please file an issue." - ); + current) + : null; } - 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." + ); } function unwindWork(workInProgress) { switch (workInProgress.tag) { @@ -5182,8 +5106,9 @@ function commitBeforeMutationLifeCycles(current$$1, finishedWork) { case 0: case 11: case 15: + case 22: commitHookEffectList(2, 0, finishedWork); - break; + return; case 1: if (finishedWork.effectTag & 256 && null !== current$$1) { var prevProps = current$$1.memoizedProps, @@ -5197,18 +5122,17 @@ function commitBeforeMutationLifeCycles(current$$1, finishedWork) { ); current$$1.__reactInternalSnapshotBeforeUpdate = finishedWork; } - break; + return; case 3: case 5: case 6: case 4: case 17: - 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." - ); + return; } + throw Error( + "This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue." + ); } function commitHookEffectList(unmountTag, mountTag, finishedWork) { finishedWork = finishedWork.updateQueue; @@ -5227,6 +5151,97 @@ function commitHookEffectList(unmountTag, mountTag, finishedWork) { } while (effect !== finishedWork); } } +function commitLifeCycles( + finishedRoot, + current$$1, + finishedWork, + committedExpirationTime +) { + switch (finishedWork.tag) { + case 0: + case 11: + case 15: + case 22: + commitHookEffectList(16, 32, finishedWork); + return; + case 1: + finishedRoot = finishedWork.stateNode; + if (finishedWork.effectTag & 4) + if (null === current$$1) finishedRoot.componentDidMount(); + else { + var prevProps = + finishedWork.elementType === finishedWork.type + ? current$$1.memoizedProps + : resolveDefaultProps( + finishedWork.type, + current$$1.memoizedProps + ); + finishedRoot.componentDidUpdate( + prevProps, + current$$1.memoizedState, + finishedRoot.__reactInternalSnapshotBeforeUpdate + ); + } + current$$1 = finishedWork.updateQueue; + null !== current$$1 && + commitUpdateQueue( + finishedWork, + current$$1, + finishedRoot, + committedExpirationTime + ); + return; + case 3: + current$$1 = finishedWork.updateQueue; + if (null !== current$$1) { + finishedRoot = null; + if (null !== finishedWork.child) + switch (finishedWork.child.tag) { + case 5: + finishedRoot = finishedWork.child.stateNode; + break; + case 1: + finishedRoot = finishedWork.child.stateNode; + } + commitUpdateQueue( + finishedWork, + current$$1, + finishedRoot, + committedExpirationTime + ); + } + return; + case 5: + return; + case 6: + return; + case 4: + return; + case 12: + committedExpirationTime = finishedWork.memoizedProps.onRender; + "function" === typeof committedExpirationTime && + committedExpirationTime( + finishedWork.memoizedProps.id, + null === current$$1 ? "mount" : "update", + finishedWork.actualDuration, + finishedWork.treeBaseDuration, + finishedWork.actualStartTime, + commitTime, + finishedRoot.memoizedInteractions + ); + return; + case 13: + return; + case 19: + case 17: + case 20: + case 21: + return; + } + throw Error( + "This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue." + ); +} function commitUnmount(finishedRoot, current$$1$jscomp$0, renderPriorityLevel) { "function" === typeof onCommitFiberUnmount && onCommitFiberUnmount(current$$1$jscomp$0); @@ -5235,6 +5250,7 @@ function commitUnmount(finishedRoot, current$$1$jscomp$0, renderPriorityLevel) { case 11: case 14: case 15: + case 22: finishedRoot = current$$1$jscomp$0.updateQueue; if ( null !== finishedRoot && @@ -5293,6 +5309,7 @@ function detachFiber(current$$1) { current$$1.lastEffect = null; current$$1.pendingProps = null; current$$1.memoizedProps = null; + current$$1.stateNode = null; null !== alternate && detachFiber(alternate); } function isHostParent(fiber) { @@ -5559,10 +5576,11 @@ function commitWork(current$$1, finishedWork) { case 11: case 14: case 15: + case 22: commitHookEffectList(4, 8, finishedWork); - break; + return; case 1: - break; + return; case 5: var instance = finishedWork.stateNode; if (null != instance) { @@ -5586,7 +5604,7 @@ function commitWork(current$$1, finishedWork) { newProps )); } - break; + return; case 6: if (null === finishedWork.stateNode) throw Error( @@ -5597,11 +5615,11 @@ function commitWork(current$$1, finishedWork) { "RCTRawText", { text: finishedWork.memoizedProps } ); - break; + return; case 3: - break; + return; case 12: - break; + return; case 13: instance = finishedWork; null === finishedWork.memoizedState @@ -5671,21 +5689,16 @@ function commitWork(current$$1, finishedWork) { current$$1 = current$$1.sibling; } attachSuspenseRetryListeners(finishedWork); - break; + return; case 19: attachSuspenseRetryListeners(finishedWork); - break; + return; case 17: - break; - case 20: - break; - case 21: - 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." - ); + return; } + throw Error( + "This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue." + ); } function attachSuspenseRetryListeners(finishedWork) { var thenables = finishedWork.updateQueue; @@ -6158,47 +6171,44 @@ function performConcurrentWorkOnRoot(root, didTimeout) { function performSyncWorkOnRoot(root) { var lastExpiredTime = root.lastExpiredTime; lastExpiredTime = 0 !== lastExpiredTime ? lastExpiredTime : 1073741823; - if (root.finishedExpirationTime === lastExpiredTime) commitRoot(root); - else { - if ((executionContext & (RenderContext | CommitContext)) !== NoContext) - throw Error("Should not already be working."); - flushPassiveEffects(); - if (root !== workInProgressRoot || lastExpiredTime !== renderExpirationTime) + if ((executionContext & (RenderContext | CommitContext)) !== NoContext) + throw Error("Should not already be working."); + flushPassiveEffects(); + if (root !== workInProgressRoot || lastExpiredTime !== renderExpirationTime) + prepareFreshStack(root, lastExpiredTime), + startWorkOnPendingInteractions(root, lastExpiredTime); + if (null !== workInProgress) { + var prevExecutionContext = executionContext; + executionContext |= RenderContext; + var prevDispatcher = pushDispatcher(root), + prevInteractions = pushInteractions(root); + do + try { + workLoopSync(); + break; + } catch (thrownValue) { + handleError(root, thrownValue); + } + while (1); + resetContextDependencies(); + executionContext = prevExecutionContext; + ReactCurrentDispatcher.current = prevDispatcher; + tracing.__interactionsRef.current = prevInteractions; + if (workInProgressRootExitStatus === RootFatalErrored) + throw ((prevExecutionContext = workInProgressRootFatalError), prepareFreshStack(root, lastExpiredTime), - startWorkOnPendingInteractions(root, lastExpiredTime); - if (null !== workInProgress) { - var prevExecutionContext = executionContext; - executionContext |= RenderContext; - var prevDispatcher = pushDispatcher(root), - prevInteractions = pushInteractions(root); - do - try { - workLoopSync(); - break; - } catch (thrownValue) { - handleError(root, thrownValue); - } - while (1); - resetContextDependencies(); - executionContext = prevExecutionContext; - ReactCurrentDispatcher.current = prevDispatcher; - tracing.__interactionsRef.current = prevInteractions; - if (workInProgressRootExitStatus === RootFatalErrored) - throw ((prevExecutionContext = workInProgressRootFatalError), - prepareFreshStack(root, lastExpiredTime), - markRootSuspendedAtTime(root, lastExpiredTime), - ensureRootIsScheduled(root), - prevExecutionContext); - if (null !== workInProgress) - throw Error( - "Cannot commit an incomplete root. This error is likely caused by a bug in React. Please file an issue." - ); - root.finishedWork = root.current.alternate; - root.finishedExpirationTime = lastExpiredTime; - workInProgressRoot = null; - commitRoot(root); - ensureRootIsScheduled(root); - } + markRootSuspendedAtTime(root, lastExpiredTime), + ensureRootIsScheduled(root), + prevExecutionContext); + if (null !== workInProgress) + throw Error( + "Cannot commit an incomplete root. This error is likely caused by a bug in React. Please file an issue." + ); + root.finishedWork = root.current.alternate; + root.finishedExpirationTime = lastExpiredTime; + workInProgressRoot = null; + commitRoot(root); + ensureRootIsScheduled(root); } return null; } @@ -6287,8 +6297,15 @@ function handleError(root$jscomp$0, thrownValue) { "object" === typeof value && "function" === typeof value.then ) { - var thenable = value, - hasInvisibleParentBoundary = + var thenable = value; + if (0 === (sourceFiber.mode & 2)) { + var currentSource = sourceFiber.alternate; + currentSource + ? ((sourceFiber.memoizedState = currentSource.memoizedState), + (sourceFiber.expirationTime = currentSource.expirationTime)) + : (sourceFiber.memoizedState = null); + } + var hasInvisibleParentBoundary = 0 !== (suspenseStackCursor.current & 1), _workInProgress = returnFiber; do { @@ -6572,7 +6589,8 @@ function commitRoot(root) { return null; } function commitRootImpl(root$jscomp$0, renderPriorityLevel$jscomp$0) { - flushPassiveEffects(); + do flushPassiveEffects(); + while (null !== rootWithPendingPassiveEffects); if ((executionContext & (RenderContext | CommitContext)) !== NoContext) throw Error("Should not already be working."); var finishedWork = root$jscomp$0.finishedWork, @@ -6691,103 +6709,24 @@ function commitRootImpl(root$jscomp$0, renderPriorityLevel$jscomp$0) { ) { var effectTag$jscomp$0 = nextEffect.effectTag; - if (effectTag$jscomp$0 & 36) { - renderPriorityLevel = effectTag; - var current$$1$jscomp$1 = nextEffect.alternate; - currentRef = nextEffect; - root = current$$1; - switch (currentRef.tag) { - case 0: - case 11: - case 15: - commitHookEffectList(16, 32, currentRef); - break; - case 1: - var instance = currentRef.stateNode; - if (currentRef.effectTag & 4) - if (null === current$$1$jscomp$1) - instance.componentDidMount(); - else { - var prevProps = - currentRef.elementType === currentRef.type - ? current$$1$jscomp$1.memoizedProps - : resolveDefaultProps( - currentRef.type, - current$$1$jscomp$1.memoizedProps - ); - instance.componentDidUpdate( - prevProps, - current$$1$jscomp$1.memoizedState, - instance.__reactInternalSnapshotBeforeUpdate - ); - } - var updateQueue = currentRef.updateQueue; - null !== updateQueue && - commitUpdateQueue(currentRef, updateQueue, instance, root); - break; - case 3: - var _updateQueue = currentRef.updateQueue; - if (null !== _updateQueue) { - renderPriorityLevel = null; - if (null !== currentRef.child) - switch (currentRef.child.tag) { - case 5: - renderPriorityLevel = currentRef.child.stateNode; - break; - case 1: - renderPriorityLevel = currentRef.child.stateNode; - } - commitUpdateQueue( - currentRef, - _updateQueue, - renderPriorityLevel, - root - ); - } - break; - case 5: - break; - case 6: - break; - case 4: - break; - case 12: - var onRender = currentRef.memoizedProps.onRender; - "function" === typeof onRender && - onRender( - currentRef.memoizedProps.id, - null === current$$1$jscomp$1 ? "mount" : "update", - currentRef.actualDuration, - currentRef.treeBaseDuration, - currentRef.actualStartTime, - commitTime, - renderPriorityLevel.memoizedInteractions - ); - break; - case 13: - break; - case 19: - case 17: - case 20: - case 21: - 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." - ); - } - } + effectTag$jscomp$0 & 36 && + commitLifeCycles( + effectTag, + nextEffect.alternate, + nextEffect, + current$$1 + ); if (effectTag$jscomp$0 & 128) { currentRef = void 0; var ref = nextEffect.ref; if (null !== ref) { - var instance$jscomp$0 = nextEffect.stateNode; + var instance = nextEffect.stateNode; switch (nextEffect.tag) { case 5: - currentRef = instance$jscomp$0; + currentRef = instance; break; default: - currentRef = instance$jscomp$0; + currentRef = instance; } "function" === typeof ref ? ref(currentRef) @@ -6827,13 +6766,13 @@ function commitRootImpl(root$jscomp$0, renderPriorityLevel$jscomp$0) { for ( remainingExpirationTimeBeforeCommit = spawnedWorkDuringRender, spawnedWorkDuringRender = null, - current$$1$jscomp$1 = 0; - current$$1$jscomp$1 < remainingExpirationTimeBeforeCommit.length; - current$$1$jscomp$1++ + ref = 0; + ref < remainingExpirationTimeBeforeCommit.length; + ref++ ) scheduleInteractions( root$jscomp$0, - remainingExpirationTimeBeforeCommit[current$$1$jscomp$1], + remainingExpirationTimeBeforeCommit[ref], root$jscomp$0.memoizedInteractions ); schedulePendingInteractions(root$jscomp$0, renderPriorityLevel$jscomp$0); @@ -6905,6 +6844,7 @@ function flushPassiveEffectsImpl() { case 0: case 11: case 15: + case 22: commitHookEffectList(128, 0, finishedWork), commitHookEffectList(0, 64, finishedWork); } @@ -7127,6 +7067,7 @@ beginWork$$1 = function(current$$1, workInProgress, renderExpirationTime) { null !== renderState.state && void 0 !== renderState.state ? renderState.state : null; + initializeUpdateQueue(workInProgress); var getDerivedStateFromProps = updateExpirationTime.getDerivedStateFromProps; "function" === typeof getDerivedStateFromProps && @@ -7164,62 +7105,63 @@ beginWork$$1 = function(current$$1, workInProgress, renderExpirationTime) { (workInProgress = workInProgress.child); return workInProgress; case 16: - renderState = workInProgress.elementType; - null !== current$$1 && - ((current$$1.alternate = null), - (workInProgress.alternate = null), - (workInProgress.effectTag |= 2)); - current$$1 = workInProgress.pendingProps; - initializeLazyComponentType(renderState); - if (1 !== renderState._status) throw renderState._result; - renderState = renderState._result; - workInProgress.type = renderState; - hasContext = workInProgress.tag = resolveLazyComponentTag(renderState); - current$$1 = resolveDefaultProps(renderState, current$$1); - switch (hasContext) { - case 0: - workInProgress = updateFunctionComponent( - null, - workInProgress, - renderState, - current$$1, - renderExpirationTime - ); - break; - case 1: - workInProgress = updateClassComponent( - null, - workInProgress, - renderState, - current$$1, - renderExpirationTime - ); - break; - case 11: - workInProgress = updateForwardRef( - null, - workInProgress, - renderState, - current$$1, - renderExpirationTime - ); - break; - case 14: - workInProgress = updateMemoComponent( - null, - workInProgress, - renderState, - resolveDefaultProps(renderState.type, current$$1), - updateExpirationTime, - renderExpirationTime - ); - break; - default: - throw Error( - "Element type is invalid. Received a promise that resolves to: " + - renderState + - ". Lazy element type must resolve to a class or function." - ); + a: { + renderState = workInProgress.elementType; + null !== current$$1 && + ((current$$1.alternate = null), + (workInProgress.alternate = null), + (workInProgress.effectTag |= 2)); + current$$1 = workInProgress.pendingProps; + initializeLazyComponentType(renderState); + if (1 !== renderState._status) throw renderState._result; + renderState = renderState._result; + workInProgress.type = renderState; + hasContext = workInProgress.tag = resolveLazyComponentTag(renderState); + current$$1 = resolveDefaultProps(renderState, current$$1); + switch (hasContext) { + case 0: + workInProgress = updateFunctionComponent( + null, + workInProgress, + renderState, + current$$1, + renderExpirationTime + ); + break a; + case 1: + workInProgress = updateClassComponent( + null, + workInProgress, + renderState, + current$$1, + renderExpirationTime + ); + break a; + case 11: + workInProgress = updateForwardRef( + null, + workInProgress, + renderState, + current$$1, + renderExpirationTime + ); + break a; + case 14: + workInProgress = updateMemoComponent( + null, + workInProgress, + renderState, + resolveDefaultProps(renderState.type, current$$1), + updateExpirationTime, + renderExpirationTime + ); + break a; + } + throw Error( + "Element type is invalid. Received a promise that resolves to: " + + renderState + + ". Lazy element type must resolve to a class or function." + ); } return workInProgress; case 0: @@ -7257,16 +7199,17 @@ beginWork$$1 = function(current$$1, workInProgress, renderExpirationTime) { case 3: pushHostRootContext(workInProgress); updateExpirationTime = workInProgress.updateQueue; - if (null === updateExpirationTime) + if (null === current$$1 || null === updateExpirationTime) throw Error( "If the root does not have an updateQueue, we should have already bailed out. This error is likely caused by a bug in React. Please file an issue." ); + updateExpirationTime = workInProgress.pendingProps; renderState = workInProgress.memoizedState; renderState = null !== renderState ? renderState.element : null; + cloneUpdateQueue(current$$1, workInProgress); processUpdateQueue( workInProgress, updateExpirationTime, - workInProgress.pendingProps, null, renderExpirationTime ); @@ -7845,6 +7788,9 @@ function createFiberFromTypeAndProps( fiberTag = 16; owner = null; break a; + case REACT_CHUNK_TYPE: + fiberTag = 22; + break a; } throw Error( "Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: " + @@ -8168,11 +8114,17 @@ var roots = new Map(), findNodeHandle: findNodeHandle, dispatchCommand: function(handle, command, args) { null != handle._nativeTag && - ReactNativePrivateInterface.UIManager.dispatchViewManagerCommand( - handle._nativeTag, - command, - args - ); + (handle._internalInstanceHandle + ? nativeFabricUIManager.dispatchCommand( + handle._internalInstanceHandle.stateNode.node, + command, + args + ) + : ReactNativePrivateInterface.UIManager.dispatchViewManagerCommand( + handle._nativeTag, + command, + args + )); }, render: function(element, containerTag, callback) { var root = roots.get(containerTag); @@ -8183,6 +8135,7 @@ var roots = new Map(), uninitializedFiber = createFiber(3, null, null, uninitializedFiber); root.current = uninitializedFiber; uninitializedFiber.stateNode = root; + initializeUpdateQueue(uninitializedFiber); roots.set(containerTag, root); } updateContainer(element, root, null, callback); @@ -8342,7 +8295,7 @@ var roots = new Map(), throw Error("getInspectorDataForViewTag() is not available in production"); }, bundleType: 0, - version: "16.11.0", + version: "16.12.0-experimental-19f6fe170", rendererPackageName: "react-native-renderer" }); var ReactNativeRenderer$2 = { default: ReactNativeRenderer }, diff --git a/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.js b/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.js index f6ef2ae04e6e38..2d39130d44b105 100644 --- a/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.js +++ b/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.js @@ -504,53 +504,27 @@ function recordTouchStart(touch) { } function recordTouchMove(touch) { var touchRecord = touchBank[getTouchIdentifier(touch)]; - touchRecord - ? ((touchRecord.touchActive = !0), - (touchRecord.previousPageX = touchRecord.currentPageX), - (touchRecord.previousPageY = touchRecord.currentPageY), - (touchRecord.previousTimeStamp = touchRecord.currentTimeStamp), - (touchRecord.currentPageX = touch.pageX), - (touchRecord.currentPageY = touch.pageY), - (touchRecord.currentTimeStamp = timestampForTouch(touch)), - (touchHistory.mostRecentTimeStamp = timestampForTouch(touch))) - : console.warn( - "Cannot record touch move without a touch start.\nTouch Move: %s\n", - "Touch Bank: %s", - printTouch(touch), - printTouchBank() - ); + touchRecord && + ((touchRecord.touchActive = !0), + (touchRecord.previousPageX = touchRecord.currentPageX), + (touchRecord.previousPageY = touchRecord.currentPageY), + (touchRecord.previousTimeStamp = touchRecord.currentTimeStamp), + (touchRecord.currentPageX = touch.pageX), + (touchRecord.currentPageY = touch.pageY), + (touchRecord.currentTimeStamp = timestampForTouch(touch)), + (touchHistory.mostRecentTimeStamp = timestampForTouch(touch))); } function recordTouchEnd(touch) { var touchRecord = touchBank[getTouchIdentifier(touch)]; - touchRecord - ? ((touchRecord.touchActive = !1), - (touchRecord.previousPageX = touchRecord.currentPageX), - (touchRecord.previousPageY = touchRecord.currentPageY), - (touchRecord.previousTimeStamp = touchRecord.currentTimeStamp), - (touchRecord.currentPageX = touch.pageX), - (touchRecord.currentPageY = touch.pageY), - (touchRecord.currentTimeStamp = timestampForTouch(touch)), - (touchHistory.mostRecentTimeStamp = timestampForTouch(touch))) - : console.warn( - "Cannot record touch end without a touch start.\nTouch End: %s\n", - "Touch Bank: %s", - printTouch(touch), - printTouchBank() - ); -} -function printTouch(touch) { - return JSON.stringify({ - identifier: touch.identifier, - pageX: touch.pageX, - pageY: touch.pageY, - timestamp: timestampForTouch(touch) - }); -} -function printTouchBank() { - var printed = JSON.stringify(touchBank.slice(0, 20)); - 20 < touchBank.length && - (printed += " (original size: " + touchBank.length + ")"); - return printed; + touchRecord && + ((touchRecord.touchActive = !1), + (touchRecord.previousPageX = touchRecord.currentPageX), + (touchRecord.previousPageY = touchRecord.currentPageY), + (touchRecord.previousTimeStamp = touchRecord.currentTimeStamp), + (touchRecord.currentPageX = touch.pageX), + (touchRecord.currentPageY = touch.pageY), + (touchRecord.currentTimeStamp = timestampForTouch(touch)), + (touchHistory.mostRecentTimeStamp = timestampForTouch(touch))); } var ResponderTouchHistoryStore = { recordTouchTrack: function(topLevelType, nativeEvent) { @@ -683,13 +657,7 @@ var eventTypes = { "topTouchCancel" === topLevelType ) if (0 <= trackedTouchCount) --trackedTouchCount; - else - return ( - console.warn( - "Ended a touch event which was not counted in `trackedTouchCount`." - ), - null - ); + else return null; ResponderTouchHistoryStore.recordTouchTrack(topLevelType, nativeEvent); if ( targetInst && @@ -1150,7 +1118,8 @@ var hasSymbol = "function" === typeof Symbol && Symbol.for, ? Symbol.for("react.suspense_list") : 60120, REACT_MEMO_TYPE = hasSymbol ? Symbol.for("react.memo") : 60115, - REACT_LAZY_TYPE = hasSymbol ? Symbol.for("react.lazy") : 60116; + REACT_LAZY_TYPE = hasSymbol ? Symbol.for("react.lazy") : 60116, + REACT_CHUNK_TYPE = hasSymbol ? Symbol.for("react.chunk") : 60121; hasSymbol && Symbol.for("react.fundamental"); hasSymbol && Symbol.for("react.responder"); hasSymbol && Symbol.for("react.scope"); @@ -1215,6 +1184,8 @@ function getComponentName(type) { ); case REACT_MEMO_TYPE: return getComponentName(type.type); + case REACT_CHUNK_TYPE: + return getComponentName(type.render); case REACT_LAZY_TYPE: if ((type = 1 === type._status ? type._result : null)) return getComponentName(type); @@ -2028,237 +1999,195 @@ function readContext(context, observedBits) { return context._currentValue; } var hasForceUpdate = !1; -function createUpdateQueue(baseState) { - return { - baseState: baseState, - firstUpdate: null, - lastUpdate: null, - firstCapturedUpdate: null, - lastCapturedUpdate: null, - firstEffect: null, - lastEffect: null, - firstCapturedEffect: null, - lastCapturedEffect: null +function initializeUpdateQueue(fiber) { + fiber.updateQueue = { + baseState: fiber.memoizedState, + baseQueue: null, + shared: { pending: null }, + effects: null }; } -function cloneUpdateQueue(currentQueue) { - return { - baseState: currentQueue.baseState, - firstUpdate: currentQueue.firstUpdate, - lastUpdate: currentQueue.lastUpdate, - firstCapturedUpdate: null, - lastCapturedUpdate: null, - firstEffect: null, - lastEffect: null, - firstCapturedEffect: null, - lastCapturedEffect: null - }; +function cloneUpdateQueue(current, workInProgress) { + current = current.updateQueue; + workInProgress.updateQueue === current && + (workInProgress.updateQueue = { + baseState: current.baseState, + baseQueue: current.baseQueue, + shared: current.shared, + effects: current.effects + }); } function createUpdate(expirationTime, suspenseConfig) { - return { + expirationTime = { expirationTime: expirationTime, suspenseConfig: suspenseConfig, tag: 0, payload: null, callback: null, - next: null, - nextEffect: null + next: null }; -} -function appendUpdateToQueue(queue, update) { - null === queue.lastUpdate - ? (queue.firstUpdate = queue.lastUpdate = update) - : ((queue.lastUpdate.next = update), (queue.lastUpdate = update)); + return (expirationTime.next = expirationTime); } function enqueueUpdate(fiber, update) { - var alternate = fiber.alternate; - if (null === alternate) { - var queue1 = fiber.updateQueue; - var queue2 = null; - null === queue1 && - (queue1 = fiber.updateQueue = createUpdateQueue(fiber.memoizedState)); - } else - (queue1 = fiber.updateQueue), - (queue2 = alternate.updateQueue), - null === queue1 - ? null === queue2 - ? ((queue1 = fiber.updateQueue = createUpdateQueue( - fiber.memoizedState - )), - (queue2 = alternate.updateQueue = createUpdateQueue( - alternate.memoizedState - ))) - : (queue1 = fiber.updateQueue = cloneUpdateQueue(queue2)) - : null === queue2 && - (queue2 = alternate.updateQueue = cloneUpdateQueue(queue1)); - null === queue2 || queue1 === queue2 - ? appendUpdateToQueue(queue1, update) - : null === queue1.lastUpdate || null === queue2.lastUpdate - ? (appendUpdateToQueue(queue1, update), - appendUpdateToQueue(queue2, update)) - : (appendUpdateToQueue(queue1, update), (queue2.lastUpdate = update)); + fiber = fiber.updateQueue; + if (null !== fiber) { + fiber = fiber.shared; + var pending = fiber.pending; + null === pending + ? (update.next = update) + : ((update.next = pending.next), (pending.next = update)); + fiber.pending = update; + } } function enqueueCapturedUpdate(workInProgress, update) { - var workInProgressQueue = workInProgress.updateQueue; - workInProgressQueue = - null === workInProgressQueue - ? (workInProgress.updateQueue = createUpdateQueue( - workInProgress.memoizedState - )) - : ensureWorkInProgressQueueIsAClone(workInProgress, workInProgressQueue); - null === workInProgressQueue.lastCapturedUpdate - ? (workInProgressQueue.firstCapturedUpdate = workInProgressQueue.lastCapturedUpdate = update) - : ((workInProgressQueue.lastCapturedUpdate.next = update), - (workInProgressQueue.lastCapturedUpdate = update)); -} -function ensureWorkInProgressQueueIsAClone(workInProgress, queue) { var current = workInProgress.alternate; - null !== current && - queue === current.updateQueue && - (queue = workInProgress.updateQueue = cloneUpdateQueue(queue)); - return queue; -} -function getStateFromUpdate( - workInProgress, - queue, - update, - prevState, - nextProps, - instance -) { - switch (update.tag) { - case 1: - return ( - (workInProgress = update.payload), - "function" === typeof workInProgress - ? workInProgress.call(instance, prevState, nextProps) - : workInProgress - ); - case 3: - workInProgress.effectTag = (workInProgress.effectTag & -4097) | 64; - case 0: - workInProgress = update.payload; - nextProps = - "function" === typeof workInProgress - ? workInProgress.call(instance, prevState, nextProps) - : workInProgress; - if (null === nextProps || void 0 === nextProps) break; - return Object.assign({}, prevState, nextProps); - case 2: - hasForceUpdate = !0; - } - return prevState; + null !== current && cloneUpdateQueue(current, workInProgress); + workInProgress = workInProgress.updateQueue; + current = workInProgress.baseQueue; + null === current + ? ((workInProgress.baseQueue = update.next = update), + (update.next = update)) + : ((update.next = current.next), (current.next = update)); } function processUpdateQueue( - workInProgress, - queue, + workInProgress$jscomp$0, props, instance, renderExpirationTime ) { + var queue = workInProgress$jscomp$0.updateQueue; hasForceUpdate = !1; - queue = ensureWorkInProgressQueueIsAClone(workInProgress, queue); - for ( - var newBaseState = queue.baseState, - newFirstUpdate = null, - newExpirationTime = 0, - update = queue.firstUpdate, - resultState = newBaseState; - null !== update; - - ) { - var updateExpirationTime = update.expirationTime; - updateExpirationTime < renderExpirationTime - ? (null === newFirstUpdate && - ((newFirstUpdate = update), (newBaseState = resultState)), - newExpirationTime < updateExpirationTime && - (newExpirationTime = updateExpirationTime)) - : (markRenderEventTimeAndConfig( - updateExpirationTime, - update.suspenseConfig - ), - (resultState = getStateFromUpdate( - workInProgress, - queue, - update, - resultState, - props, - instance - )), - null !== update.callback && - ((workInProgress.effectTag |= 32), - (update.nextEffect = null), - null === queue.lastEffect - ? (queue.firstEffect = queue.lastEffect = update) - : ((queue.lastEffect.nextEffect = update), - (queue.lastEffect = update)))); - update = update.next; + var baseQueue = queue.baseQueue, + pendingQueue = queue.shared.pending; + if (null !== pendingQueue) { + if (null !== baseQueue) { + var baseFirst = baseQueue.next; + baseQueue.next = pendingQueue.next; + pendingQueue.next = baseFirst; + } + baseQueue = pendingQueue; + queue.shared.pending = null; + baseFirst = workInProgress$jscomp$0.alternate; + null !== baseFirst && + ((baseFirst = baseFirst.updateQueue), + null !== baseFirst && (baseFirst.baseQueue = pendingQueue)); } - updateExpirationTime = null; - for (update = queue.firstCapturedUpdate; null !== update; ) { - var _updateExpirationTime = update.expirationTime; - _updateExpirationTime < renderExpirationTime - ? (null === updateExpirationTime && - ((updateExpirationTime = update), - null === newFirstUpdate && (newBaseState = resultState)), - newExpirationTime < _updateExpirationTime && - (newExpirationTime = _updateExpirationTime)) - : ((resultState = getStateFromUpdate( - workInProgress, - queue, - update, - resultState, - props, - instance - )), - null !== update.callback && - ((workInProgress.effectTag |= 32), - (update.nextEffect = null), - null === queue.lastCapturedEffect - ? (queue.firstCapturedEffect = queue.lastCapturedEffect = update) - : ((queue.lastCapturedEffect.nextEffect = update), - (queue.lastCapturedEffect = update)))); - update = update.next; + if (null !== baseQueue) { + baseFirst = baseQueue.next; + var newState = queue.baseState, + newExpirationTime = 0, + newBaseState = null, + newBaseQueueFirst = null, + newBaseQueueLast = null; + if (null !== baseFirst) { + var update = baseFirst; + do { + pendingQueue = update.expirationTime; + if (pendingQueue < renderExpirationTime) { + var clone = { + expirationTime: update.expirationTime, + suspenseConfig: update.suspenseConfig, + tag: update.tag, + payload: update.payload, + callback: update.callback, + next: null + }; + null === newBaseQueueLast + ? ((newBaseQueueFirst = newBaseQueueLast = clone), + (newBaseState = newState)) + : (newBaseQueueLast = newBaseQueueLast.next = clone); + pendingQueue > newExpirationTime && + (newExpirationTime = pendingQueue); + } else { + null !== newBaseQueueLast && + (newBaseQueueLast = newBaseQueueLast.next = { + expirationTime: 1073741823, + suspenseConfig: update.suspenseConfig, + tag: update.tag, + payload: update.payload, + callback: update.callback, + next: null + }); + markRenderEventTimeAndConfig(pendingQueue, update.suspenseConfig); + a: { + var workInProgress = workInProgress$jscomp$0, + update$jscomp$0 = update; + pendingQueue = props; + clone = instance; + switch (update$jscomp$0.tag) { + case 1: + workInProgress = update$jscomp$0.payload; + if ("function" === typeof workInProgress) { + newState = workInProgress.call(clone, newState, pendingQueue); + break a; + } + newState = workInProgress; + break a; + case 3: + workInProgress.effectTag = + (workInProgress.effectTag & -4097) | 64; + case 0: + workInProgress = update$jscomp$0.payload; + pendingQueue = + "function" === typeof workInProgress + ? workInProgress.call(clone, newState, pendingQueue) + : workInProgress; + if (null === pendingQueue || void 0 === pendingQueue) break a; + newState = Object.assign({}, newState, pendingQueue); + break a; + case 2: + hasForceUpdate = !0; + } + } + null !== update.callback && + ((workInProgress$jscomp$0.effectTag |= 32), + (pendingQueue = queue.effects), + null === pendingQueue + ? (queue.effects = [update]) + : pendingQueue.push(update)); + } + update = update.next; + if (null === update || update === baseFirst) + if (((pendingQueue = queue.shared.pending), null === pendingQueue)) + break; + else + (update = baseQueue.next = pendingQueue.next), + (pendingQueue.next = baseFirst), + (queue.baseQueue = baseQueue = pendingQueue), + (queue.shared.pending = null); + } while (1); + } + null === newBaseQueueLast + ? (newBaseState = newState) + : (newBaseQueueLast.next = newBaseQueueFirst); + queue.baseState = newBaseState; + queue.baseQueue = newBaseQueueLast; + markUnprocessedUpdateTime(newExpirationTime); + workInProgress$jscomp$0.expirationTime = newExpirationTime; + workInProgress$jscomp$0.memoizedState = newState; } - null === newFirstUpdate && (queue.lastUpdate = null); - null === updateExpirationTime - ? (queue.lastCapturedUpdate = null) - : (workInProgress.effectTag |= 32); - null === newFirstUpdate && - null === updateExpirationTime && - (newBaseState = resultState); - queue.baseState = newBaseState; - queue.firstUpdate = newFirstUpdate; - queue.firstCapturedUpdate = updateExpirationTime; - markUnprocessedUpdateTime(newExpirationTime); - workInProgress.expirationTime = newExpirationTime; - workInProgress.memoizedState = resultState; } function commitUpdateQueue(finishedWork, finishedQueue, instance) { - null !== finishedQueue.firstCapturedUpdate && - (null !== finishedQueue.lastUpdate && - ((finishedQueue.lastUpdate.next = finishedQueue.firstCapturedUpdate), - (finishedQueue.lastUpdate = finishedQueue.lastCapturedUpdate)), - (finishedQueue.firstCapturedUpdate = finishedQueue.lastCapturedUpdate = null)); - commitUpdateEffects(finishedQueue.firstEffect, instance); - finishedQueue.firstEffect = finishedQueue.lastEffect = null; - commitUpdateEffects(finishedQueue.firstCapturedEffect, instance); - finishedQueue.firstCapturedEffect = finishedQueue.lastCapturedEffect = null; -} -function commitUpdateEffects(effect, instance) { - for (; null !== effect; ) { - var callback = effect.callback; - if (null !== callback) { - effect.callback = null; - if ("function" !== typeof callback) - throw Error( - "Invalid argument passed as callback. Expected a function. Instead received: " + - callback - ); - callback.call(instance); + finishedWork = finishedQueue.effects; + finishedQueue.effects = null; + if (null !== finishedWork) + for ( + finishedQueue = 0; + finishedQueue < finishedWork.length; + finishedQueue++ + ) { + var effect = finishedWork[finishedQueue], + callback = effect.callback; + if (null !== callback) { + effect.callback = null; + if ("function" !== typeof callback) + throw Error( + "Invalid argument passed as callback. Expected a function. Instead received: " + + callback + ); + callback.call(instance); + } } - effect = effect.nextEffect; - } } var ReactCurrentBatchConfig = ReactSharedInternals.ReactCurrentBatchConfig, emptyRefsObject = new React.Component().refs; @@ -2275,10 +2204,8 @@ function applyDerivedStateFromProps( ? ctor : Object.assign({}, ctor, getDerivedStateFromProps); workInProgress.memoizedState = getDerivedStateFromProps; - nextProps = workInProgress.updateQueue; - null !== nextProps && - 0 === workInProgress.expirationTime && - (nextProps.baseState = getDerivedStateFromProps); + 0 === workInProgress.expirationTime && + (workInProgress.updateQueue.baseState = getDerivedStateFromProps); } var classComponentUpdater = { isMounted: function(component) { @@ -2393,6 +2320,7 @@ function mountClassInstance( instance.props = newProps; instance.state = workInProgress.memoizedState; instance.refs = emptyRefsObject; + initializeUpdateQueue(workInProgress); var contextType = ctor.contextType; "object" === typeof contextType && null !== contextType ? (instance.context = readContext(contextType)) @@ -2400,16 +2328,8 @@ function mountClassInstance( ? previousContext : contextStackCursor.current), (instance.context = getMaskedContext(workInProgress, contextType))); - contextType = workInProgress.updateQueue; - null !== contextType && - (processUpdateQueue( - workInProgress, - contextType, - newProps, - instance, - renderExpirationTime - ), - (instance.state = workInProgress.memoizedState)); + processUpdateQueue(workInProgress, newProps, instance, renderExpirationTime); + instance.state = workInProgress.memoizedState; contextType = ctor.getDerivedStateFromProps; "function" === typeof contextType && (applyDerivedStateFromProps(workInProgress, ctor, contextType, newProps), @@ -2425,16 +2345,13 @@ function mountClassInstance( instance.UNSAFE_componentWillMount(), ctor !== instance.state && classComponentUpdater.enqueueReplaceState(instance, instance.state, null), - (contextType = workInProgress.updateQueue), - null !== contextType && - (processUpdateQueue( - workInProgress, - contextType, - newProps, - instance, - renderExpirationTime - ), - (instance.state = workInProgress.memoizedState))); + processUpdateQueue( + workInProgress, + newProps, + instance, + renderExpirationTime + ), + (instance.state = workInProgress.memoizedState)); "function" === typeof instance.componentDidMount && (workInProgress.effectTag |= 4); } @@ -2996,39 +2913,50 @@ function ChildReconciler(shouldTrackSideEffects) { null !== isUnkeyedTopLevelFragment; ) { - if (isUnkeyedTopLevelFragment.key === isObject) - if ( - 7 === isUnkeyedTopLevelFragment.tag - ? newChild.type === REACT_FRAGMENT_TYPE - : isUnkeyedTopLevelFragment.elementType === newChild.type - ) { - deleteRemainingChildren( - returnFiber, - isUnkeyedTopLevelFragment.sibling - ); - currentFirstChild = useFiber( - isUnkeyedTopLevelFragment, - newChild.type === REACT_FRAGMENT_TYPE - ? newChild.props.children - : newChild.props, - expirationTime - ); - currentFirstChild.ref = coerceRef( - returnFiber, - isUnkeyedTopLevelFragment, - newChild - ); - currentFirstChild.return = returnFiber; - returnFiber = currentFirstChild; - break a; - } else { - deleteRemainingChildren( - returnFiber, - isUnkeyedTopLevelFragment - ); - break; + if (isUnkeyedTopLevelFragment.key === isObject) { + switch (isUnkeyedTopLevelFragment.tag) { + case 7: + if (newChild.type === REACT_FRAGMENT_TYPE) { + deleteRemainingChildren( + returnFiber, + isUnkeyedTopLevelFragment.sibling + ); + currentFirstChild = useFiber( + isUnkeyedTopLevelFragment, + newChild.props.children, + expirationTime + ); + currentFirstChild.return = returnFiber; + returnFiber = currentFirstChild; + break a; + } + break; + default: + if ( + isUnkeyedTopLevelFragment.elementType === newChild.type + ) { + deleteRemainingChildren( + returnFiber, + isUnkeyedTopLevelFragment.sibling + ); + currentFirstChild = useFiber( + isUnkeyedTopLevelFragment, + newChild.props, + expirationTime + ); + currentFirstChild.ref = coerceRef( + returnFiber, + isUnkeyedTopLevelFragment, + newChild + ); + currentFirstChild.return = returnFiber; + returnFiber = currentFirstChild; + break a; + } } - else deleteChild(returnFiber, isUnkeyedTopLevelFragment); + deleteRemainingChildren(returnFiber, isUnkeyedTopLevelFragment); + break; + } else deleteChild(returnFiber, isUnkeyedTopLevelFragment); isUnkeyedTopLevelFragment = isUnkeyedTopLevelFragment.sibling; } newChild.type === REACT_FRAGMENT_TYPE @@ -3226,7 +3154,7 @@ function findFirstSuspended(row) { } return null; } -function createResponderListener(responder, props) { +function createDeprecatedResponderListener(responder, props) { return { responder: responder, props: props }; } var ReactCurrentDispatcher$1 = ReactSharedInternals.ReactCurrentDispatcher, @@ -3234,13 +3162,7 @@ var ReactCurrentDispatcher$1 = ReactSharedInternals.ReactCurrentDispatcher, renderExpirationTime$1 = 0, currentlyRenderingFiber$1 = null, currentHook = null, - nextCurrentHook = null, - firstWorkInProgressHook = null, workInProgressHook = null, - nextWorkInProgressHook = null, - remainingExpirationTime = 0, - componentUpdateQueue = null, - sideEffectTag = 0, didScheduleRenderPhaseUpdate = !1, renderPhaseUpdates = null, numberOfReRenders = 0; @@ -3260,53 +3182,45 @@ function renderWithHooks( workInProgress, Component, props, - refOrContext, + secondArg, nextRenderExpirationTime ) { renderExpirationTime$1 = nextRenderExpirationTime; currentlyRenderingFiber$1 = workInProgress; - nextCurrentHook = null !== current ? current.memoizedState : null; + workInProgress.memoizedState = null; + workInProgress.updateQueue = null; + workInProgress.expirationTime = 0; ReactCurrentDispatcher$1.current = - null === nextCurrentHook ? HooksDispatcherOnMount : HooksDispatcherOnUpdate; - workInProgress = Component(props, refOrContext); + null === current || null === current.memoizedState + ? HooksDispatcherOnMount + : HooksDispatcherOnUpdate; + current = Component(props, secondArg); if (didScheduleRenderPhaseUpdate) { do (didScheduleRenderPhaseUpdate = !1), (numberOfReRenders += 1), - (nextCurrentHook = null !== current ? current.memoizedState : null), - (nextWorkInProgressHook = firstWorkInProgressHook), - (componentUpdateQueue = workInProgressHook = currentHook = null), + (workInProgressHook = currentHook = null), + (workInProgress.updateQueue = null), (ReactCurrentDispatcher$1.current = HooksDispatcherOnUpdate), - (workInProgress = Component(props, refOrContext)); + (current = Component(props, secondArg)); while (didScheduleRenderPhaseUpdate); renderPhaseUpdates = null; numberOfReRenders = 0; } ReactCurrentDispatcher$1.current = ContextOnlyDispatcher; - current = currentlyRenderingFiber$1; - current.memoizedState = firstWorkInProgressHook; - current.expirationTime = remainingExpirationTime; - current.updateQueue = componentUpdateQueue; - current.effectTag |= sideEffectTag; - current = null !== currentHook && null !== currentHook.next; + workInProgress = null !== currentHook && null !== currentHook.next; renderExpirationTime$1 = 0; - nextWorkInProgressHook = workInProgressHook = firstWorkInProgressHook = nextCurrentHook = currentHook = currentlyRenderingFiber$1 = null; - remainingExpirationTime = 0; - componentUpdateQueue = null; - sideEffectTag = 0; - if (current) + workInProgressHook = currentHook = currentlyRenderingFiber$1 = null; + if (workInProgress) throw Error( "Rendered fewer hooks than expected. This may be caused by an accidental early return statement." ); - return workInProgress; + return current; } function resetHooks() { ReactCurrentDispatcher$1.current = ContextOnlyDispatcher; renderExpirationTime$1 = 0; - nextWorkInProgressHook = workInProgressHook = firstWorkInProgressHook = nextCurrentHook = currentHook = currentlyRenderingFiber$1 = null; - remainingExpirationTime = 0; - componentUpdateQueue = null; - sideEffectTag = 0; + workInProgressHook = currentHook = currentlyRenderingFiber$1 = null; didScheduleRenderPhaseUpdate = !1; renderPhaseUpdates = null; numberOfReRenders = 0; @@ -3315,37 +3229,42 @@ function mountWorkInProgressHook() { var hook = { memoizedState: null, baseState: null, + baseQueue: null, queue: null, - baseUpdate: null, next: null }; null === workInProgressHook - ? (firstWorkInProgressHook = workInProgressHook = hook) + ? (currentlyRenderingFiber$1.memoizedState = workInProgressHook = hook) : (workInProgressHook = workInProgressHook.next = hook); return workInProgressHook; } function updateWorkInProgressHook() { + if (null === currentHook) { + var nextCurrentHook = currentlyRenderingFiber$1.alternate; + nextCurrentHook = + null !== nextCurrentHook ? nextCurrentHook.memoizedState : null; + } else nextCurrentHook = currentHook.next; + var nextWorkInProgressHook = + null === workInProgressHook + ? currentlyRenderingFiber$1.memoizedState + : workInProgressHook.next; if (null !== nextWorkInProgressHook) (workInProgressHook = nextWorkInProgressHook), - (nextWorkInProgressHook = workInProgressHook.next), - (currentHook = nextCurrentHook), - (nextCurrentHook = null !== currentHook ? currentHook.next : null); + (currentHook = nextCurrentHook); else { if (null === nextCurrentHook) throw Error("Rendered more hooks than during the previous render."); currentHook = nextCurrentHook; - var newHook = { + nextCurrentHook = { memoizedState: currentHook.memoizedState, baseState: currentHook.baseState, + baseQueue: currentHook.baseQueue, queue: currentHook.queue, - baseUpdate: currentHook.baseUpdate, next: null }; - workInProgressHook = - null === workInProgressHook - ? (firstWorkInProgressHook = newHook) - : (workInProgressHook.next = newHook); - nextCurrentHook = currentHook.next; + null === workInProgressHook + ? (currentlyRenderingFiber$1.memoizedState = workInProgressHook = nextCurrentHook) + : (workInProgressHook = workInProgressHook.next = nextCurrentHook); } return workInProgressHook; } @@ -3373,51 +3292,75 @@ function updateReducer(reducer) { while (null !== firstRenderPhaseUpdate); is$1(newState, hook.memoizedState) || (didReceiveUpdate = !0); hook.memoizedState = newState; - hook.baseUpdate === queue.last && (hook.baseState = newState); + null === hook.baseQueue && (hook.baseState = newState); queue.lastRenderedState = newState; return [newState, _dispatch]; } } return [hook.memoizedState, _dispatch]; } - _dispatch = queue.last; - var baseUpdate = hook.baseUpdate; - newState = hook.baseState; - null !== baseUpdate - ? (null !== _dispatch && (_dispatch.next = null), - (_dispatch = baseUpdate.next)) - : (_dispatch = null !== _dispatch ? _dispatch.next : null); + newState = currentHook; + _dispatch = newState.baseQueue; + firstRenderPhaseUpdate = queue.pending; + if (null !== firstRenderPhaseUpdate) { + if (null !== _dispatch) { + var baseFirst = _dispatch.next; + _dispatch.next = firstRenderPhaseUpdate.next; + firstRenderPhaseUpdate.next = baseFirst; + } + newState.baseQueue = _dispatch = firstRenderPhaseUpdate; + queue.pending = null; + } if (null !== _dispatch) { - var newBaseUpdate = (firstRenderPhaseUpdate = null), - _update = _dispatch, - didSkip = !1; + _dispatch = _dispatch.next; + newState = newState.baseState; + var newBaseQueueLast = (baseFirst = firstRenderPhaseUpdate = null), + _update = _dispatch; do { var updateExpirationTime = _update.expirationTime; - updateExpirationTime < renderExpirationTime$1 - ? (didSkip || - ((didSkip = !0), - (newBaseUpdate = baseUpdate), - (firstRenderPhaseUpdate = newState)), - updateExpirationTime > remainingExpirationTime && - ((remainingExpirationTime = updateExpirationTime), - markUnprocessedUpdateTime(remainingExpirationTime))) - : (markRenderEventTimeAndConfig( + if (updateExpirationTime < renderExpirationTime$1) { + var clone = { + expirationTime: _update.expirationTime, + suspenseConfig: _update.suspenseConfig, + action: _update.action, + eagerReducer: _update.eagerReducer, + eagerState: _update.eagerState, + next: null + }; + null === newBaseQueueLast + ? ((baseFirst = newBaseQueueLast = clone), + (firstRenderPhaseUpdate = newState)) + : (newBaseQueueLast = newBaseQueueLast.next = clone); + updateExpirationTime > currentlyRenderingFiber$1.expirationTime && + ((currentlyRenderingFiber$1.expirationTime = updateExpirationTime), + markUnprocessedUpdateTime(updateExpirationTime)); + } else + null !== newBaseQueueLast && + (newBaseQueueLast = newBaseQueueLast.next = { + expirationTime: 1073741823, + suspenseConfig: _update.suspenseConfig, + action: _update.action, + eagerReducer: _update.eagerReducer, + eagerState: _update.eagerState, + next: null + }), + markRenderEventTimeAndConfig( updateExpirationTime, _update.suspenseConfig ), (newState = _update.eagerReducer === reducer ? _update.eagerState - : reducer(newState, _update.action))); - baseUpdate = _update; + : reducer(newState, _update.action)); _update = _update.next; } while (null !== _update && _update !== _dispatch); - didSkip || - ((newBaseUpdate = baseUpdate), (firstRenderPhaseUpdate = newState)); + null === newBaseQueueLast + ? (firstRenderPhaseUpdate = newState) + : (newBaseQueueLast.next = baseFirst); is$1(newState, hook.memoizedState) || (didReceiveUpdate = !0); hook.memoizedState = newState; - hook.baseUpdate = newBaseUpdate; hook.baseState = firstRenderPhaseUpdate; + hook.baseQueue = newBaseQueueLast; queue.lastRenderedState = newState; } return [hook.memoizedState, queue.dispatch]; @@ -3427,7 +3370,7 @@ function mountState(initialState) { "function" === typeof initialState && (initialState = initialState()); hook.memoizedState = hook.baseState = initialState; initialState = hook.queue = { - last: null, + pending: null, dispatch: null, lastRenderedReducer: basicStateReducer, lastRenderedState: initialState @@ -3444,21 +3387,23 @@ function updateState(initialState) { } function pushEffect(tag, create, destroy, deps) { tag = { tag: tag, create: create, destroy: destroy, deps: deps, next: null }; - null === componentUpdateQueue - ? ((componentUpdateQueue = { lastEffect: null }), - (componentUpdateQueue.lastEffect = tag.next = tag)) - : ((create = componentUpdateQueue.lastEffect), - null === create - ? (componentUpdateQueue.lastEffect = tag.next = tag) - : ((destroy = create.next), - (create.next = tag), - (tag.next = destroy), - (componentUpdateQueue.lastEffect = tag))); + create = currentlyRenderingFiber$1.updateQueue; + null === create + ? ((create = { lastEffect: null }), + (currentlyRenderingFiber$1.updateQueue = create), + (create.lastEffect = tag.next = tag)) + : ((destroy = create.lastEffect), + null === destroy + ? (create.lastEffect = tag.next = tag) + : ((deps = destroy.next), + (destroy.next = tag), + (tag.next = deps), + (create.lastEffect = tag))); return tag; } function mountEffectImpl(fiberEffectTag, hookEffectTag, create, deps) { var hook = mountWorkInProgressHook(); - sideEffectTag |= fiberEffectTag; + currentlyRenderingFiber$1.effectTag |= fiberEffectTag; hook.memoizedState = pushEffect( hookEffectTag, create, @@ -3478,7 +3423,7 @@ function updateEffectImpl(fiberEffectTag, hookEffectTag, create, deps) { return; } } - sideEffectTag |= fiberEffectTag; + currentlyRenderingFiber$1.effectTag |= fiberEffectTag; hook.memoizedState = pushEffect(hookEffectTag, create, destroy, deps); } function mountEffect(create, deps) { @@ -3526,6 +3471,21 @@ function updateCallback(callback, deps) { hook.memoizedState = [callback, deps]; return callback; } +function startTransition(setPending, config, callback) { + var priorityLevel = getCurrentPriorityLevel(); + runWithPriority(98 > priorityLevel ? 98 : priorityLevel, function() { + setPending(!0); + }); + runWithPriority(97 < priorityLevel ? 97 : priorityLevel, function() { + var previousConfig = ReactCurrentBatchConfig$1.suspense; + ReactCurrentBatchConfig$1.suspense = void 0 === config ? null : config; + try { + setPending(!1), callback(); + } finally { + ReactCurrentBatchConfig$1.suspense = previousConfig; + } + }); +} function dispatchAction(fiber, queue, action) { if (!(25 > numberOfReRenders)) throw Error( @@ -3567,14 +3527,11 @@ function dispatchAction(fiber, queue, action) { eagerState: null, next: null }; - var last = queue.last; - if (null === last) suspenseConfig.next = suspenseConfig; - else { - var first = last.next; - null !== first && (suspenseConfig.next = first); - last.next = suspenseConfig; - } - queue.last = suspenseConfig; + var pending = queue.pending; + null === pending + ? (suspenseConfig.next = suspenseConfig) + : ((suspenseConfig.next = pending.next), (pending.next = suspenseConfig)); + queue.pending = suspenseConfig; if ( 0 === fiber.expirationTime && (null === alternate || 0 === alternate.expirationTime) && @@ -3637,7 +3594,7 @@ var ContextOnlyDispatcher = { initialArg = void 0 !== init ? init(initialArg) : initialArg; hook.memoizedState = hook.baseState = initialArg; reducer = hook.queue = { - last: null, + pending: null, dispatch: null, lastRenderedReducer: reducer, lastRenderedState: initialArg @@ -3656,23 +3613,21 @@ var ContextOnlyDispatcher = { }, useState: mountState, useDebugValue: mountDebugValue, - useResponder: createResponderListener, + useResponder: createDeprecatedResponderListener, useDeferredValue: function(value, config) { var _mountState = mountState(value), prevValue = _mountState[0], setValue = _mountState[1]; mountEffect( function() { - Scheduler.unstable_next(function() { - var previousConfig = ReactCurrentBatchConfig$1.suspense; - ReactCurrentBatchConfig$1.suspense = - void 0 === config ? null : config; - try { - setValue(value); - } finally { - ReactCurrentBatchConfig$1.suspense = previousConfig; - } - }); + var previousConfig = ReactCurrentBatchConfig$1.suspense; + ReactCurrentBatchConfig$1.suspense = + void 0 === config ? null : config; + try { + setValue(value); + } finally { + ReactCurrentBatchConfig$1.suspense = previousConfig; + } }, [value, config] ); @@ -3680,25 +3635,13 @@ var ContextOnlyDispatcher = { }, useTransition: function(config) { var _mountState2 = mountState(!1), - isPending = _mountState2[0], - setPending = _mountState2[1]; + isPending = _mountState2[0]; + _mountState2 = _mountState2[1]; return [ - mountCallback( - function(callback) { - setPending(!0); - Scheduler.unstable_next(function() { - var previousConfig = ReactCurrentBatchConfig$1.suspense; - ReactCurrentBatchConfig$1.suspense = - void 0 === config ? null : config; - try { - setPending(!1), callback(); - } finally { - ReactCurrentBatchConfig$1.suspense = previousConfig; - } - }); - }, - [config, isPending] - ), + mountCallback(startTransition.bind(null, _mountState2, config), [ + _mountState2, + config + ]), isPending ]; } @@ -3740,23 +3683,21 @@ var ContextOnlyDispatcher = { }, useState: updateState, useDebugValue: mountDebugValue, - useResponder: createResponderListener, + useResponder: createDeprecatedResponderListener, useDeferredValue: function(value, config) { var _updateState = updateState(value), prevValue = _updateState[0], setValue = _updateState[1]; updateEffect( function() { - Scheduler.unstable_next(function() { - var previousConfig = ReactCurrentBatchConfig$1.suspense; - ReactCurrentBatchConfig$1.suspense = - void 0 === config ? null : config; - try { - setValue(value); - } finally { - ReactCurrentBatchConfig$1.suspense = previousConfig; - } - }); + var previousConfig = ReactCurrentBatchConfig$1.suspense; + ReactCurrentBatchConfig$1.suspense = + void 0 === config ? null : config; + try { + setValue(value); + } finally { + ReactCurrentBatchConfig$1.suspense = previousConfig; + } }, [value, config] ); @@ -3764,25 +3705,13 @@ var ContextOnlyDispatcher = { }, useTransition: function(config) { var _updateState2 = updateState(!1), - isPending = _updateState2[0], - setPending = _updateState2[1]; + isPending = _updateState2[0]; + _updateState2 = _updateState2[1]; return [ - updateCallback( - function(callback) { - setPending(!0); - Scheduler.unstable_next(function() { - var previousConfig = ReactCurrentBatchConfig$1.suspense; - ReactCurrentBatchConfig$1.suspense = - void 0 === config ? null : config; - try { - setPending(!1), callback(); - } finally { - ReactCurrentBatchConfig$1.suspense = previousConfig; - } - }); - }, - [config, isPending] - ), + updateCallback(startTransition.bind(null, _updateState2, config), [ + _updateState2, + config + ]), isPending ]; } @@ -4107,17 +4036,14 @@ function updateClassComponent( )); hasForceUpdate = !1; var oldState = workInProgress.memoizedState; - oldContext = instance.state = oldState; - var updateQueue = workInProgress.updateQueue; - null !== updateQueue && - (processUpdateQueue( - workInProgress, - updateQueue, - nextProps, - instance, - renderExpirationTime - ), - (oldContext = workInProgress.memoizedState)); + instance.state = oldState; + processUpdateQueue( + workInProgress, + nextProps, + instance, + renderExpirationTime + ); + oldContext = workInProgress.memoizedState; oldProps !== nextProps || oldState !== oldContext || didPerformWorkStackCursor.current || @@ -4163,6 +4089,7 @@ function updateClassComponent( (nextProps = !1)); } else (instance = workInProgress.stateNode), + cloneUpdateQueue(current$$1, workInProgress), (oldProps = workInProgress.memoizedProps), (instance.props = workInProgress.type === workInProgress.elementType @@ -4191,17 +4118,14 @@ function updateClassComponent( )), (hasForceUpdate = !1), (oldContext = workInProgress.memoizedState), - (oldState = instance.state = oldContext), - (updateQueue = workInProgress.updateQueue), - null !== updateQueue && - (processUpdateQueue( - workInProgress, - updateQueue, - nextProps, - instance, - renderExpirationTime - ), - (oldState = workInProgress.memoizedState)), + (instance.state = oldContext), + processUpdateQueue( + workInProgress, + nextProps, + instance, + renderExpirationTime + ), + (oldState = workInProgress.memoizedState), oldProps !== nextProps || oldContext !== oldState || didPerformWorkStackCursor.current || @@ -4521,6 +4445,7 @@ function initSuspenseListRenderState( ? (workInProgress.memoizedState = { isBackwards: isBackwards, rendering: null, + renderingStartTime: 0, last: lastContentRow, tail: tail, tailExpiration: 0, @@ -4529,6 +4454,7 @@ function initSuspenseListRenderState( }) : ((renderState.isBackwards = isBackwards), (renderState.rendering = null), + (renderState.renderingStartTime = 0), (renderState.last = lastContentRow), (renderState.tail = tail), (renderState.tailExpiration = 0), @@ -4740,24 +4666,32 @@ function completeWork(current, workInProgress, renderExpirationTime$jscomp$0) { var newProps = workInProgress.pendingProps; switch (workInProgress.tag) { case 2: - break; case 16: - break; case 15: case 0: - break; + case 11: + case 7: + case 8: + case 12: + case 9: + case 14: + return null; case 1: - isContextProvider(workInProgress.type) && popContext(workInProgress); - break; + return ( + isContextProvider(workInProgress.type) && popContext(workInProgress), + null + ); case 3: - popHostContainer(workInProgress); - popTopLevelContextObject(workInProgress); - current = workInProgress.stateNode; - current.pendingContext && - ((current.context = current.pendingContext), - (current.pendingContext = null)); - updateHostContainer(workInProgress); - break; + return ( + popHostContainer(workInProgress), + popTopLevelContextObject(workInProgress), + (current = workInProgress.stateNode), + current.pendingContext && + ((current.context = current.pendingContext), + (current.pendingContext = null)), + updateHostContainer(workInProgress), + null + ); case 5: popHostContext(workInProgress); var rootContainerInstance = requiredContext( @@ -4774,7 +4708,14 @@ function completeWork(current, workInProgress, renderExpirationTime$jscomp$0) { ), current.ref !== workInProgress.ref && (workInProgress.effectTag |= 128); - else if (newProps) { + 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." + ); + return null; + } current = requiredContext(contextStackCursor$1.current); var tag = allocateTag(), viewConfig = getViewConfigForType(renderExpirationTime$jscomp$0), @@ -4803,11 +4744,8 @@ function completeWork(current, workInProgress, renderExpirationTime$jscomp$0) { current ) && (workInProgress.effectTag |= 4); null !== workInProgress.ref && (workInProgress.effectTag |= 128); - } else 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." - ); - break; + } + return null; case 6: if (current && null != workInProgress.stateNode) updateHostText$1( @@ -4836,9 +4774,7 @@ function completeWork(current, workInProgress, renderExpirationTime$jscomp$0) { instanceCache.set(rootContainerInstance, workInProgress); workInProgress.stateNode = rootContainerInstance; } - break; - case 11: - break; + return null; case 13: pop(suspenseStackCursor, workInProgress); newProps = workInProgress.memoizedState; @@ -4886,31 +4822,24 @@ function completeWork(current, workInProgress, renderExpirationTime$jscomp$0) { )); } if (newProps || rootContainerInstance) workInProgress.effectTag |= 4; - break; - case 7: - break; - case 8: - break; - case 12: - break; + return null; case 4: - popHostContainer(workInProgress); - updateHostContainer(workInProgress); - break; + return ( + popHostContainer(workInProgress), + updateHostContainer(workInProgress), + null + ); case 10: - popProvider(workInProgress); - break; - case 9: - break; - case 14: - break; + return popProvider(workInProgress), null; case 17: - isContextProvider(workInProgress.type) && popContext(workInProgress); - break; + return ( + isContextProvider(workInProgress.type) && popContext(workInProgress), + null + ); case 19: pop(suspenseStackCursor, workInProgress); newProps = workInProgress.memoizedState; - if (null === newProps) break; + if (null === newProps) return null; rootContainerInstance = 0 !== (workInProgress.effectTag & 64); tag = newProps.rendering; if (null === tag) @@ -5002,13 +4931,15 @@ function completeWork(current, workInProgress, renderExpirationTime$jscomp$0) { null === newProps.tail && "hidden" === newProps.tailMode && !tag.alternate) - ) { - workInProgress = workInProgress.lastEffect = newProps.lastEffect; - null !== workInProgress && (workInProgress.nextEffect = null); - break; - } + ) + return ( + (workInProgress = workInProgress.lastEffect = + newProps.lastEffect), + null !== workInProgress && (workInProgress.nextEffect = null), + null + ); } else - now() > newProps.tailExpiration && + 2 * now() - newProps.renderingStartTime > newProps.tailExpiration && 1 < renderExpirationTime$jscomp$0 && ((workInProgress.effectTag |= 64), (rootContainerInstance = !0), @@ -5026,14 +4957,14 @@ function completeWork(current, workInProgress, renderExpirationTime$jscomp$0) { : (workInProgress.child = tag), (newProps.last = tag)); } - if (null !== newProps.tail) - return ( - 0 === newProps.tailExpiration && + return null !== newProps.tail + ? (0 === newProps.tailExpiration && (newProps.tailExpiration = now() + 500), (current = newProps.tail), (newProps.rendering = current), (newProps.tail = current.sibling), (newProps.lastEffect = workInProgress.lastEffect), + (newProps.renderingStartTime = now()), (current.sibling = null), (newProps = suspenseStackCursor.current), push( @@ -5041,21 +4972,14 @@ function completeWork(current, workInProgress, renderExpirationTime$jscomp$0) { rootContainerInstance ? (newProps & 1) | 2 : newProps & 1, workInProgress ), - current - ); - break; - case 20: - break; - case 21: - break; - default: - throw Error( - "Unknown unit of work tag (" + - workInProgress.tag + - "). This error is likely caused by a bug in React. Please file an issue." - ); + current) + : null; } - 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." + ); } function unwindWork(workInProgress) { switch (workInProgress.tag) { @@ -5172,8 +5096,9 @@ function commitBeforeMutationLifeCycles(current$$1, finishedWork) { case 0: case 11: case 15: + case 22: commitHookEffectList(2, 0, finishedWork); - break; + return; case 1: if (finishedWork.effectTag & 256 && null !== current$$1) { var prevProps = current$$1.memoizedProps, @@ -5187,18 +5112,17 @@ function commitBeforeMutationLifeCycles(current$$1, finishedWork) { ); current$$1.__reactInternalSnapshotBeforeUpdate = finishedWork; } - break; + return; case 3: case 5: case 6: case 4: case 17: - 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." - ); + return; } + throw Error( + "This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue." + ); } function commitHookEffectList(unmountTag, mountTag, finishedWork) { finishedWork = finishedWork.updateQueue; @@ -5217,6 +5141,97 @@ function commitHookEffectList(unmountTag, mountTag, finishedWork) { } while (effect !== finishedWork); } } +function commitLifeCycles( + finishedRoot, + current$$1, + finishedWork, + committedExpirationTime +) { + switch (finishedWork.tag) { + case 0: + case 11: + case 15: + case 22: + commitHookEffectList(16, 32, finishedWork); + return; + case 1: + finishedRoot = finishedWork.stateNode; + if (finishedWork.effectTag & 4) + if (null === current$$1) finishedRoot.componentDidMount(); + else { + var prevProps = + finishedWork.elementType === finishedWork.type + ? current$$1.memoizedProps + : resolveDefaultProps( + finishedWork.type, + current$$1.memoizedProps + ); + finishedRoot.componentDidUpdate( + prevProps, + current$$1.memoizedState, + finishedRoot.__reactInternalSnapshotBeforeUpdate + ); + } + current$$1 = finishedWork.updateQueue; + null !== current$$1 && + commitUpdateQueue( + finishedWork, + current$$1, + finishedRoot, + committedExpirationTime + ); + return; + case 3: + current$$1 = finishedWork.updateQueue; + if (null !== current$$1) { + finishedRoot = null; + if (null !== finishedWork.child) + switch (finishedWork.child.tag) { + case 5: + finishedRoot = finishedWork.child.stateNode; + break; + case 1: + finishedRoot = finishedWork.child.stateNode; + } + commitUpdateQueue( + finishedWork, + current$$1, + finishedRoot, + committedExpirationTime + ); + } + return; + case 5: + return; + case 6: + return; + case 4: + return; + case 12: + committedExpirationTime = finishedWork.memoizedProps.onRender; + "function" === typeof committedExpirationTime && + committedExpirationTime( + finishedWork.memoizedProps.id, + null === current$$1 ? "mount" : "update", + finishedWork.actualDuration, + finishedWork.treeBaseDuration, + finishedWork.actualStartTime, + commitTime, + finishedRoot.memoizedInteractions + ); + return; + case 13: + return; + case 19: + case 17: + case 20: + case 21: + return; + } + throw Error( + "This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue." + ); +} function commitUnmount(finishedRoot, current$$1$jscomp$0, renderPriorityLevel) { "function" === typeof onCommitFiberUnmount && onCommitFiberUnmount(current$$1$jscomp$0); @@ -5225,6 +5240,7 @@ function commitUnmount(finishedRoot, current$$1$jscomp$0, renderPriorityLevel) { case 11: case 14: case 15: + case 22: finishedRoot = current$$1$jscomp$0.updateQueue; if ( null !== finishedRoot && @@ -5283,6 +5299,7 @@ function detachFiber(current$$1) { current$$1.lastEffect = null; current$$1.pendingProps = null; current$$1.memoizedProps = null; + current$$1.stateNode = null; null !== alternate && detachFiber(alternate); } function isHostParent(fiber) { @@ -5549,10 +5566,11 @@ function commitWork(current$$1, finishedWork) { case 11: case 14: case 15: + case 22: commitHookEffectList(4, 8, finishedWork); - break; + return; case 1: - break; + return; case 5: var instance = finishedWork.stateNode; if (null != instance) { @@ -5576,7 +5594,7 @@ function commitWork(current$$1, finishedWork) { newProps )); } - break; + return; case 6: if (null === finishedWork.stateNode) throw Error( @@ -5587,11 +5605,11 @@ function commitWork(current$$1, finishedWork) { "RCTRawText", { text: finishedWork.memoizedProps } ); - break; + return; case 3: - break; + return; case 12: - break; + return; case 13: instance = finishedWork; null === finishedWork.memoizedState @@ -5661,21 +5679,16 @@ function commitWork(current$$1, finishedWork) { current$$1 = current$$1.sibling; } attachSuspenseRetryListeners(finishedWork); - break; + return; case 19: attachSuspenseRetryListeners(finishedWork); - break; + return; case 17: - break; - case 20: - break; - case 21: - 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." - ); + return; } + throw Error( + "This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue." + ); } function attachSuspenseRetryListeners(finishedWork) { var thenables = finishedWork.updateQueue; @@ -6148,47 +6161,44 @@ function performConcurrentWorkOnRoot(root, didTimeout) { function performSyncWorkOnRoot(root) { var lastExpiredTime = root.lastExpiredTime; lastExpiredTime = 0 !== lastExpiredTime ? lastExpiredTime : 1073741823; - if (root.finishedExpirationTime === lastExpiredTime) commitRoot(root); - else { - if ((executionContext & (RenderContext | CommitContext)) !== NoContext) - throw Error("Should not already be working."); - flushPassiveEffects(); - if (root !== workInProgressRoot || lastExpiredTime !== renderExpirationTime) + if ((executionContext & (RenderContext | CommitContext)) !== NoContext) + throw Error("Should not already be working."); + flushPassiveEffects(); + if (root !== workInProgressRoot || lastExpiredTime !== renderExpirationTime) + prepareFreshStack(root, lastExpiredTime), + startWorkOnPendingInteractions(root, lastExpiredTime); + if (null !== workInProgress) { + var prevExecutionContext = executionContext; + executionContext |= RenderContext; + var prevDispatcher = pushDispatcher(root), + prevInteractions = pushInteractions(root); + do + try { + workLoopSync(); + break; + } catch (thrownValue) { + handleError(root, thrownValue); + } + while (1); + resetContextDependencies(); + executionContext = prevExecutionContext; + ReactCurrentDispatcher.current = prevDispatcher; + tracing.__interactionsRef.current = prevInteractions; + if (workInProgressRootExitStatus === RootFatalErrored) + throw ((prevExecutionContext = workInProgressRootFatalError), prepareFreshStack(root, lastExpiredTime), - startWorkOnPendingInteractions(root, lastExpiredTime); - if (null !== workInProgress) { - var prevExecutionContext = executionContext; - executionContext |= RenderContext; - var prevDispatcher = pushDispatcher(root), - prevInteractions = pushInteractions(root); - do - try { - workLoopSync(); - break; - } catch (thrownValue) { - handleError(root, thrownValue); - } - while (1); - resetContextDependencies(); - executionContext = prevExecutionContext; - ReactCurrentDispatcher.current = prevDispatcher; - tracing.__interactionsRef.current = prevInteractions; - if (workInProgressRootExitStatus === RootFatalErrored) - throw ((prevExecutionContext = workInProgressRootFatalError), - prepareFreshStack(root, lastExpiredTime), - markRootSuspendedAtTime(root, lastExpiredTime), - ensureRootIsScheduled(root), - prevExecutionContext); - if (null !== workInProgress) - throw Error( - "Cannot commit an incomplete root. This error is likely caused by a bug in React. Please file an issue." - ); - root.finishedWork = root.current.alternate; - root.finishedExpirationTime = lastExpiredTime; - workInProgressRoot = null; - commitRoot(root); - ensureRootIsScheduled(root); - } + markRootSuspendedAtTime(root, lastExpiredTime), + ensureRootIsScheduled(root), + prevExecutionContext); + if (null !== workInProgress) + throw Error( + "Cannot commit an incomplete root. This error is likely caused by a bug in React. Please file an issue." + ); + root.finishedWork = root.current.alternate; + root.finishedExpirationTime = lastExpiredTime; + workInProgressRoot = null; + commitRoot(root); + ensureRootIsScheduled(root); } return null; } @@ -6277,8 +6287,15 @@ function handleError(root$jscomp$0, thrownValue) { "object" === typeof value && "function" === typeof value.then ) { - var thenable = value, - hasInvisibleParentBoundary = + var thenable = value; + if (0 === (sourceFiber.mode & 2)) { + var currentSource = sourceFiber.alternate; + currentSource + ? ((sourceFiber.memoizedState = currentSource.memoizedState), + (sourceFiber.expirationTime = currentSource.expirationTime)) + : (sourceFiber.memoizedState = null); + } + var hasInvisibleParentBoundary = 0 !== (suspenseStackCursor.current & 1), _workInProgress = returnFiber; do { @@ -6562,7 +6579,8 @@ function commitRoot(root) { return null; } function commitRootImpl(root$jscomp$0, renderPriorityLevel$jscomp$0) { - flushPassiveEffects(); + do flushPassiveEffects(); + while (null !== rootWithPendingPassiveEffects); if ((executionContext & (RenderContext | CommitContext)) !== NoContext) throw Error("Should not already be working."); var finishedWork = root$jscomp$0.finishedWork, @@ -6681,103 +6699,24 @@ function commitRootImpl(root$jscomp$0, renderPriorityLevel$jscomp$0) { ) { var effectTag$jscomp$0 = nextEffect.effectTag; - if (effectTag$jscomp$0 & 36) { - renderPriorityLevel = effectTag; - var current$$1$jscomp$1 = nextEffect.alternate; - currentRef = nextEffect; - root = current$$1; - switch (currentRef.tag) { - case 0: - case 11: - case 15: - commitHookEffectList(16, 32, currentRef); - break; - case 1: - var instance = currentRef.stateNode; - if (currentRef.effectTag & 4) - if (null === current$$1$jscomp$1) - instance.componentDidMount(); - else { - var prevProps = - currentRef.elementType === currentRef.type - ? current$$1$jscomp$1.memoizedProps - : resolveDefaultProps( - currentRef.type, - current$$1$jscomp$1.memoizedProps - ); - instance.componentDidUpdate( - prevProps, - current$$1$jscomp$1.memoizedState, - instance.__reactInternalSnapshotBeforeUpdate - ); - } - var updateQueue = currentRef.updateQueue; - null !== updateQueue && - commitUpdateQueue(currentRef, updateQueue, instance, root); - break; - case 3: - var _updateQueue = currentRef.updateQueue; - if (null !== _updateQueue) { - renderPriorityLevel = null; - if (null !== currentRef.child) - switch (currentRef.child.tag) { - case 5: - renderPriorityLevel = currentRef.child.stateNode; - break; - case 1: - renderPriorityLevel = currentRef.child.stateNode; - } - commitUpdateQueue( - currentRef, - _updateQueue, - renderPriorityLevel, - root - ); - } - break; - case 5: - break; - case 6: - break; - case 4: - break; - case 12: - var onRender = currentRef.memoizedProps.onRender; - "function" === typeof onRender && - onRender( - currentRef.memoizedProps.id, - null === current$$1$jscomp$1 ? "mount" : "update", - currentRef.actualDuration, - currentRef.treeBaseDuration, - currentRef.actualStartTime, - commitTime, - renderPriorityLevel.memoizedInteractions - ); - break; - case 13: - break; - case 19: - case 17: - case 20: - case 21: - 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." - ); - } - } + effectTag$jscomp$0 & 36 && + commitLifeCycles( + effectTag, + nextEffect.alternate, + nextEffect, + current$$1 + ); if (effectTag$jscomp$0 & 128) { currentRef = void 0; var ref = nextEffect.ref; if (null !== ref) { - var instance$jscomp$0 = nextEffect.stateNode; + var instance = nextEffect.stateNode; switch (nextEffect.tag) { case 5: - currentRef = instance$jscomp$0; + currentRef = instance; break; default: - currentRef = instance$jscomp$0; + currentRef = instance; } "function" === typeof ref ? ref(currentRef) @@ -6817,13 +6756,13 @@ function commitRootImpl(root$jscomp$0, renderPriorityLevel$jscomp$0) { for ( remainingExpirationTimeBeforeCommit = spawnedWorkDuringRender, spawnedWorkDuringRender = null, - current$$1$jscomp$1 = 0; - current$$1$jscomp$1 < remainingExpirationTimeBeforeCommit.length; - current$$1$jscomp$1++ + ref = 0; + ref < remainingExpirationTimeBeforeCommit.length; + ref++ ) scheduleInteractions( root$jscomp$0, - remainingExpirationTimeBeforeCommit[current$$1$jscomp$1], + remainingExpirationTimeBeforeCommit[ref], root$jscomp$0.memoizedInteractions ); schedulePendingInteractions(root$jscomp$0, renderPriorityLevel$jscomp$0); @@ -6895,6 +6834,7 @@ function flushPassiveEffectsImpl() { case 0: case 11: case 15: + case 22: commitHookEffectList(128, 0, finishedWork), commitHookEffectList(0, 64, finishedWork); } @@ -7117,6 +7057,7 @@ beginWork$$1 = function(current$$1, workInProgress, renderExpirationTime) { null !== renderState.state && void 0 !== renderState.state ? renderState.state : null; + initializeUpdateQueue(workInProgress); var getDerivedStateFromProps = updateExpirationTime.getDerivedStateFromProps; "function" === typeof getDerivedStateFromProps && @@ -7154,62 +7095,63 @@ beginWork$$1 = function(current$$1, workInProgress, renderExpirationTime) { (workInProgress = workInProgress.child); return workInProgress; case 16: - renderState = workInProgress.elementType; - null !== current$$1 && - ((current$$1.alternate = null), - (workInProgress.alternate = null), - (workInProgress.effectTag |= 2)); - current$$1 = workInProgress.pendingProps; - initializeLazyComponentType(renderState); - if (1 !== renderState._status) throw renderState._result; - renderState = renderState._result; - workInProgress.type = renderState; - hasContext = workInProgress.tag = resolveLazyComponentTag(renderState); - current$$1 = resolveDefaultProps(renderState, current$$1); - switch (hasContext) { - case 0: - workInProgress = updateFunctionComponent( - null, - workInProgress, - renderState, - current$$1, - renderExpirationTime - ); - break; - case 1: - workInProgress = updateClassComponent( - null, - workInProgress, - renderState, - current$$1, - renderExpirationTime - ); - break; - case 11: - workInProgress = updateForwardRef( - null, - workInProgress, - renderState, - current$$1, - renderExpirationTime - ); - break; - case 14: - workInProgress = updateMemoComponent( - null, - workInProgress, - renderState, - resolveDefaultProps(renderState.type, current$$1), - updateExpirationTime, - renderExpirationTime - ); - break; - default: - throw Error( - "Element type is invalid. Received a promise that resolves to: " + - renderState + - ". Lazy element type must resolve to a class or function." - ); + a: { + renderState = workInProgress.elementType; + null !== current$$1 && + ((current$$1.alternate = null), + (workInProgress.alternate = null), + (workInProgress.effectTag |= 2)); + current$$1 = workInProgress.pendingProps; + initializeLazyComponentType(renderState); + if (1 !== renderState._status) throw renderState._result; + renderState = renderState._result; + workInProgress.type = renderState; + hasContext = workInProgress.tag = resolveLazyComponentTag(renderState); + current$$1 = resolveDefaultProps(renderState, current$$1); + switch (hasContext) { + case 0: + workInProgress = updateFunctionComponent( + null, + workInProgress, + renderState, + current$$1, + renderExpirationTime + ); + break a; + case 1: + workInProgress = updateClassComponent( + null, + workInProgress, + renderState, + current$$1, + renderExpirationTime + ); + break a; + case 11: + workInProgress = updateForwardRef( + null, + workInProgress, + renderState, + current$$1, + renderExpirationTime + ); + break a; + case 14: + workInProgress = updateMemoComponent( + null, + workInProgress, + renderState, + resolveDefaultProps(renderState.type, current$$1), + updateExpirationTime, + renderExpirationTime + ); + break a; + } + throw Error( + "Element type is invalid. Received a promise that resolves to: " + + renderState + + ". Lazy element type must resolve to a class or function." + ); } return workInProgress; case 0: @@ -7247,16 +7189,17 @@ beginWork$$1 = function(current$$1, workInProgress, renderExpirationTime) { case 3: pushHostRootContext(workInProgress); updateExpirationTime = workInProgress.updateQueue; - if (null === updateExpirationTime) + if (null === current$$1 || null === updateExpirationTime) throw Error( "If the root does not have an updateQueue, we should have already bailed out. This error is likely caused by a bug in React. Please file an issue." ); + updateExpirationTime = workInProgress.pendingProps; renderState = workInProgress.memoizedState; renderState = null !== renderState ? renderState.element : null; + cloneUpdateQueue(current$$1, workInProgress); processUpdateQueue( workInProgress, updateExpirationTime, - workInProgress.pendingProps, null, renderExpirationTime ); @@ -7835,6 +7778,9 @@ function createFiberFromTypeAndProps( fiberTag = 16; owner = null; break a; + case REACT_CHUNK_TYPE: + fiberTag = 22; + break a; } throw Error( "Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: " + @@ -8158,11 +8104,17 @@ var roots = new Map(), findNodeHandle: findNodeHandle, dispatchCommand: function(handle, command, args) { null != handle._nativeTag && - ReactNativePrivateInterface.UIManager.dispatchViewManagerCommand( - handle._nativeTag, - command, - args - ); + (handle._internalInstanceHandle + ? nativeFabricUIManager.dispatchCommand( + handle._internalInstanceHandle.stateNode.node, + command, + args + ) + : ReactNativePrivateInterface.UIManager.dispatchViewManagerCommand( + handle._nativeTag, + command, + args + )); }, render: function(element, containerTag, callback) { var root = roots.get(containerTag); @@ -8173,6 +8125,7 @@ var roots = new Map(), uninitializedFiber = createFiber(3, null, null, uninitializedFiber); root.current = uninitializedFiber; uninitializedFiber.stateNode = root; + initializeUpdateQueue(uninitializedFiber); roots.set(containerTag, root); } updateContainer(element, root, null, callback); @@ -8332,7 +8285,7 @@ var roots = new Map(), throw Error("getInspectorDataForViewTag() is not available in production"); }, bundleType: 0, - version: "16.11.0", + version: "16.12.0-19f6fe170", rendererPackageName: "react-native-renderer" }); var ReactNativeRenderer$2 = { default: ReactNativeRenderer }, diff --git a/Libraries/Renderer/shims/ReactNativeTypes.js b/Libraries/Renderer/shims/ReactNativeTypes.js index cf20ce938c2760..013058a996e974 100644 --- a/Libraries/Renderer/shims/ReactNativeTypes.js +++ b/Libraries/Renderer/shims/ReactNativeTypes.js @@ -204,51 +204,3 @@ export type ReactFaricEvent = { target: number, ... }; - -export type ReactNativeResponderEvent = { - nativeEvent: ReactFaricEvent, - target: null | ReactNativeEventTarget, - type: string, - ... -}; - -export type ReactNativeResponderContext = { - dispatchEvent: ( - eventValue: any, - listener: (any) => void, - eventPriority: EventPriority, - ) => void, - isTargetWithinNode: ( - childTarget: ReactNativeEventTarget, - parentTarget: ReactNativeEventTarget, - ) => boolean, - getTargetBoundingRect( - target: ReactNativeEventTarget, - cb: ({ - left: number, - right: number, - top: number, - bottom: number, - ... - }) => void, - ): void, - addRootEventTypes: (rootEventTypes: Array) => void, - removeRootEventTypes: (rootEventTypes: Array) => void, - getTimeStamp: () => number, - getResponderNode(): ReactNativeEventTarget | null, - ... -}; - -export type PointerType = - | '' - | 'mouse' - | 'keyboard' - | 'pen' - | 'touch' - | 'trackpad'; - -export type EventPriority = 0 | 1 | 2; - -export const DiscreteEvent: EventPriority = 0; -export const UserBlockingEvent: EventPriority = 1; -export const ContinuousEvent: EventPriority = 2; diff --git a/package.json b/package.json index dc7aeba02ad726..e6381a2d9bb8c9 100644 --- a/package.json +++ b/package.json @@ -82,7 +82,7 @@ "test-ios": "./scripts/objc-test.sh test" }, "peerDependencies": { - "react": "16.11.0" + "react": "16.12.0" }, "dependencies": { "@babel/runtime": "^7.0.0", @@ -112,7 +112,7 @@ "react-devtools-core": "^4.0.6", "react-refresh": "^0.4.0", "regenerator-runtime": "^0.13.2", - "scheduler": "0.17.0", + "scheduler": "0.18.0", "stacktrace-parser": "^0.1.3", "use-subscription": "^1.0.0", "whatwg-fetch": "^3.0.0" @@ -148,8 +148,8 @@ "jscodeshift": "^0.6.2", "mkdirp": "^0.5.1", "prettier": "1.17.0", - "react": "16.11.0", - "react-test-renderer": "16.11.0", + "react": "16.12.0", + "react-test-renderer": "16.12.0", "shelljs": "^0.7.8", "signedsource": "^1.0.0", "ws": "^6.1.4", diff --git a/template/package.json b/template/package.json index 513cd7474d888c..36fad4a1bb64f2 100644 --- a/template/package.json +++ b/template/package.json @@ -9,7 +9,7 @@ "test": "jest" }, "dependencies": { - "react": "16.11.0", + "react": "16.12.0", "react-native": "1000.0.0" }, "devDependencies": { @@ -19,7 +19,7 @@ "babel-jest": "^24.9.0", "jest": "^24.9.0", "metro-react-native-babel-preset": "^0.56.0", - "react-test-renderer": "16.11.0" + "react-test-renderer": "16.12.0" }, "jest": { "preset": "react-native" diff --git a/yarn.lock b/yarn.lock index 6dc7390b8a9555..facb8b1112f78d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6222,20 +6222,20 @@ react-refresh@^0.4.0: resolved "https://registry.yarnpkg.com/react-refresh/-/react-refresh-0.4.0.tgz#d421f9bd65e0e4b9822a399f14ac56bda9c92292" integrity sha512-bacjSio8GOtzNZKZZM6EWqbhlbb6pr28JWJWFTLwEBKvPIBRo6/Ob68D2EWZA2VyTdQxAh+TRnCYOPNKsQiXTA== -react-test-renderer@16.11.0: - version "16.11.0" - resolved "https://registry.yarnpkg.com/react-test-renderer/-/react-test-renderer-16.11.0.tgz#72574566496462c808ac449b0287a4c0a1a7d8f8" - integrity sha512-nh9gDl8R4ut+ZNNb2EeKO5VMvTKxwzurbSMuGBoKtjpjbg8JK/u3eVPVNi1h1Ue+eYK9oSzJjb+K3lzLxyA4ag== +react-test-renderer@16.12.0: + version "16.12.0" + resolved "https://registry.yarnpkg.com/react-test-renderer/-/react-test-renderer-16.12.0.tgz#11417ffda579306d4e841a794d32140f3da1b43f" + integrity sha512-Vj/teSqt2oayaWxkbhQ6gKis+t5JrknXfPVo+aIJ8QwYAqMPH77uptOdrlphyxl8eQI/rtkOYg86i/UWkpFu0w== dependencies: object-assign "^4.1.1" prop-types "^15.6.2" react-is "^16.8.6" - scheduler "^0.17.0" + scheduler "^0.18.0" -react@16.11.0: - version "16.11.0" - resolved "https://registry.yarnpkg.com/react/-/react-16.11.0.tgz#d294545fe62299ccee83363599bf904e4a07fdbb" - integrity sha512-M5Y8yITaLmU0ynd0r1Yvfq98Rmll6q8AxaEe88c8e7LxO8fZ2cNgmFt0aGAS9wzf1Ao32NKXtCl+/tVVtkxq6g== +react@16.12.0: + version "16.12.0" + resolved "https://registry.yarnpkg.com/react/-/react-16.12.0.tgz#0c0a9c6a142429e3614834d5a778e18aa78a0b83" + integrity sha512-fglqy3k5E+81pA8s+7K0/T3DBCF0ZDOher1elBFzF7O6arXJgzyu/FW+COxFvAWXJoJN9KIZbT2LXlukwphYTA== dependencies: loose-envify "^1.1.0" object-assign "^4.1.1" @@ -6630,10 +6630,10 @@ sax@^1.2.1, sax@^1.2.4: resolved "https://registry.yarnpkg.com/sax/-/sax-1.2.4.tgz#2816234e2378bddc4e5354fab5caa895df7100d9" integrity sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw== -scheduler@0.17.0, scheduler@^0.17.0: - version "0.17.0" - resolved "https://registry.yarnpkg.com/scheduler/-/scheduler-0.17.0.tgz#7c9c673e4ec781fac853927916d1c426b6f3ddfe" - integrity sha512-7rro8Io3tnCPuY4la/NuI5F2yfESpnfZyT6TtkXnSWVkcu0BCDJ+8gk5ozUaFaxpIyNuWAPXrH0yFcSi28fnDA== +scheduler@0.18.0, scheduler@^0.18.0: + version "0.18.0" + resolved "https://registry.yarnpkg.com/scheduler/-/scheduler-0.18.0.tgz#5901ad6659bc1d8f3fdaf36eb7a67b0d6746b1c4" + integrity sha512-agTSHR1Nbfi6ulI0kYNK0203joW2Y5W4po4l+v03tOoiJKpTBbxpNhWDvqc/4IcOw+KLmSiQLTasZ4cab2/UWQ== dependencies: loose-envify "^1.1.0" object-assign "^4.1.1"