From 7142e9b1c5f95e82ceb04798b166318385004147 Mon Sep 17 00:00:00 2001 From: Tim Yung Date: Fri, 5 Oct 2018 18:08:06 -0700 Subject: [PATCH] React sync for revisions ade5e69...d836010 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Summary: This sync includes the following changes: - **[d83601080](https://github.com/facebook/react/commit/d83601080)**: Wrap retrySuspendedRoot using SchedulerTracing (#13776) //// - **[40a521aa7](https://github.com/facebook/react/commit/40a521aa7)**: Terminology: Functional -> Function Component (#13775) //// - **[605ab10a4](https://github.com/facebook/react/commit/605ab10a4)**: Add envify transform to scheduler package (#13766) //// - **[acc7f404c](https://github.com/facebook/react/commit/acc7f404c)**: Restart from root if promise pings before end of render phase (#13774) //// - **[cbc224028](https://github.com/facebook/react/commit/cbc224028)**: fix - small misspelling (#13768) //// - **[4eabeef11](https://github.com/facebook/react/commit/4eabeef11)**: Rename ReactSuspenseWithTestRenderer-test -> ReactSuspense-test //// - **[95a3e1c2e](https://github.com/facebook/react/commit/95a3e1c2e)**: Rename ReactSuspense-test -> ReactSuspenseWithNoopRenderer-test //// - **[96bcae9d5](https://github.com/facebook/react/commit/96bcae9d5)**: Jest + test renderer helpers for concurrent mode (#13751) //// - **[5c783ee75](https://github.com/facebook/react/commit/5c783ee75)**: Remove unreachable code (#13762) //// - **[36c5d69ca](https://github.com/facebook/react/commit/36c5d69ca)**: Always warn about legacy context within StrictMode tree (#13760) //// - **[3e9a5de88](https://github.com/facebook/react/commit/3e9a5de88)**: UMD react-cache build (#13761) //// - **[8315a30b9](https://github.com/facebook/react/commit/8315a30b9)**: --save is no longer needed (#13756) //// - **[ce96e2df4](https://github.com/facebook/react/commit/ce96e2df4)**: Rename simple-cache-provider to react-cache (#13755) //// - **[c5212646f](https://github.com/facebook/react/commit/c5212646f)**: Removed extra typeof checks for contextType.unstable_read (#13736) //// - **[806eebdae](https://github.com/facebook/react/commit/806eebdae)**: Enable getDerivedStateFromError (#13746) //// - **[a0733fe13](https://github.com/facebook/react/commit/a0733fe13)**: pure (#13748) //// - **[4d17c3f05](https://github.com/facebook/react/commit/4d17c3f05)**: [scheduler] Improve naive fallback version used in non-DOM environments //// - **[469005d87](https://github.com/facebook/react/commit/469005d87)**: Revise `AttributeType` React Native Flow Type (#13737) //// - **[0dc0ddc1e](https://github.com/facebook/react/commit/0dc0ddc1e)**: Rename AsyncMode -> ConcurrentMode (#13732) //// - **[7601c3765](https://github.com/facebook/react/commit/7601c3765)**: Ensure "addEventListener" exists on "window" for "scheduler" package (#13731) //// - **[d0c0ec98e](https://github.com/facebook/react/commit/d0c0ec98e)**: Added a PureComponent contextType test (#13729) //// - **[4b68a6498](https://github.com/facebook/react/commit/4b68a6498)**: Support class component static contextType attribute (#13728) //// - **[f305d2a48](https://github.com/facebook/react/commit/f305d2a48)**: [scheduler] Priority levels, continuations, and wrapped callbacks (#13720) //// - **[970a34bae](https://github.com/facebook/react/commit/970a34bae)**: Bump babel-eslint and remove flow supressions (#13727) //// - **[13965b4d3](https://github.com/facebook/react/commit/13965b4d3)**: Interaction tracking ref-counting bug fixes (WIP) (#13590) //// - **[17e703cb9](https://github.com/facebook/react/commit/17e703cb9)**: Restore global window.event after event dispatching (#13688) (#13697) //// - **[a775a767a](https://github.com/facebook/react/commit/a775a767a)**: Remove redundant logic (#13502) //// - **[e1a067dea](https://github.com/facebook/react/commit/e1a067dea)**: Fix circular dependency in TracingSubscriptions (#13689) //// - **[518812eeb](https://github.com/facebook/react/commit/518812eeb)**: Clarify comment (#13684) //// - **[eeb817785](https://github.com/facebook/react/commit/eeb817785)**: Remove some old files from stats //// - **[7ea3ca1d1](https://github.com/facebook/react/commit/7ea3ca1d1)**: Rename schedule to scheduler (#13683) //// - **[bec2ddaf1](https://github.com/facebook/react/commit/bec2ddaf1)**: Update bundle sizes for 16.5.2 release //// - **[4269fafb0](https://github.com/facebook/react/commit/4269fafb0)**: Updating package versions for release 16.5.2 //// - **[4380f9ba1](https://github.com/facebook/react/commit/4380f9ba1)**: Revert "Updating package versions for release 16.6.0-alpha.0" //// - **[72fad84e7](https://github.com/facebook/react/commit/72fad84e7)**: Revert "Updating dependencies for react-noop-renderer" //// - **[c3fad5acf](https://github.com/facebook/react/commit/c3fad5acf)**: Revert "Update bundle sizes for 16.6.0-alpha.0 release" //// - **[dd9120561](https://github.com/facebook/react/commit/dd9120561)**: Kepp calling peformWork consistent (#13596) //// - **[42d12317a](https://github.com/facebook/react/commit/42d12317a)**: Update bundle sizes for 16.6.0-alpha.0 release //// - **[489614c4f](https://github.com/facebook/react/commit/489614c4f)**: Updating dependencies for react-noop-renderer //// - **[351c9015c](https://github.com/facebook/react/commit/351c9015c)**: Updating package versions for release 16.6.0-alpha.0 //// - **[a210b5b44](https://github.com/facebook/react/commit/a210b5b44)**: Revert "Do not bind topLevelType to dispatch" (#13674) //// - **[1d8a75fef](https://github.com/facebook/react/commit/1d8a75fef)**: remove flow typings from Schedule.js (#13662) //// - **[d92114b98](https://github.com/facebook/react/commit/d92114b98)**: Resubmit: Fix updateWrapper causing re-render textarea, even though their data (#13643) //// - **[0c9c591bf](https://github.com/facebook/react/commit/0c9c591bf)**: Do not bind topLevelType to dispatch (#13618) //// - **[9f819a5ea](https://github.com/facebook/react/commit/9f819a5ea)**: [schedule] Refactor Schedule, remove React-isms (#13582) //// - **[9c961c0a2](https://github.com/facebook/react/commit/9c961c0a2)**: Fix some iframe edge cases (#13650) //// - **[8bc0bcabe](https://github.com/facebook/react/commit/8bc0bcabe)**: Add UMD production+profiling entry points (#13642) //// - **[b488a5d9c](https://github.com/facebook/react/commit/b488a5d9c)**: Fix test comment typo (#13568) //// - **[4bcee5621](https://github.com/facebook/react/commit/4bcee5621)**: Rename "tracking" API to "tracing" (#13641) //// - **[72217d081](https://github.com/facebook/react/commit/72217d081)**: Update bundle sizes for 16.5.1 release //// - **[8b93a60c5](https://github.com/facebook/react/commit/8b93a60c5)**: Updating package versions for release 16.5.1 //// - **[ecbf7af40](https://github.com/facebook/react/commit/ecbf7af40)**: Enhance dev warnings for forwardRef render function (#13627) (#13636) //// - **[228240085](https://github.com/facebook/react/commit/228240085)**: Delete TapEventPlugin (#13630) //// - **[a079011f9](https://github.com/facebook/react/commit/a079011f9)**: ð Stop syncing the value attribute on inputs (behind a feature flag) (#13526) //// - **[a7bd7c3c0](https://github.com/facebook/react/commit/a7bd7c3c0)**: Allow reading default feature flags from bundle tests (#13629) //// - **[d3bbfe09c](https://github.com/facebook/react/commit/d3bbfe09c)**: Fix IE version in comment //// - **[1b2646a40](https://github.com/facebook/react/commit/1b2646a40)**: Fix warning without stack for ie9 (#13620) //// - **[e49f3ca08](https://github.com/facebook/react/commit/e49f3ca08)**: honor displayName set on ForwardRef if available (#13615) //// Release Notes: [GENERAL] [FEATURE] [React] - React sync for revisions ade5e69...d836010 Reviewed By: bvaughn Differential Revision: D10118547 fbshipit-source-id: ecde7ada80331abdc8bd7d279e0f3dbe9acde071 --- Libraries/Renderer/README.md | 3 - Libraries/Renderer/REVISION | 2 +- Libraries/Renderer/oss/ReactFabric-dev.js | 1201 ++++++++++------- Libraries/Renderer/oss/ReactFabric-prod.js | 952 +++++++------ .../Renderer/oss/ReactFabric-profiling.js | 1153 ++++++++-------- .../Renderer/oss/ReactNativeRenderer-dev.js | 1197 +++++++++------- .../Renderer/oss/ReactNativeRenderer-prod.js | 952 +++++++------ .../oss/ReactNativeRenderer-profiling.js | 1149 ++++++++-------- Libraries/Renderer/shims/ReactTypes.js | 2 - package.json | 6 +- 10 files changed, 3743 insertions(+), 2874 deletions(-) delete mode 100644 Libraries/Renderer/README.md diff --git a/Libraries/Renderer/README.md b/Libraries/Renderer/README.md deleted file mode 100644 index 60d96d53224dec..00000000000000 --- a/Libraries/Renderer/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# WARNING - -### The code in the `oss` folder is sync'ed from the React repo. Please submit a pull request on https://github.com/facebook/react/tree/master/packages/react-native-renderer if you want to make changes. diff --git a/Libraries/Renderer/REVISION b/Libraries/Renderer/REVISION index 1526108b0c87a5..d655480ee26935 100644 --- a/Libraries/Renderer/REVISION +++ b/Libraries/Renderer/REVISION @@ -1 +1 @@ -ade5e692883345783e32e87875bbb744fb415c9c \ No newline at end of file +d83601080a7c913cedcfbad86044702d008039c7 \ No newline at end of file diff --git a/Libraries/Renderer/oss/ReactFabric-dev.js b/Libraries/Renderer/oss/ReactFabric-dev.js index 410669cb533e03..1e886eebc5a936 100644 --- a/Libraries/Renderer/oss/ReactFabric-dev.js +++ b/Libraries/Renderer/oss/ReactFabric-dev.js @@ -26,7 +26,7 @@ var deepFreezeAndThrowOnMutationInDev = require("deepFreezeAndThrowOnMutationInD var TextInputState = require("TextInputState"); var FabricUIManager = require("FabricUIManager"); var checkPropTypes = require("prop-types/checkPropTypes"); -var tracking = require("schedule/tracking"); +var tracing = require("scheduler/tracing"); var ExceptionsManager = require("ExceptionsManager"); /** @@ -165,6 +165,13 @@ var invokeGuardedCallbackImpl = function( // browsers that support it. var windowEvent = window.event; + // Keeps track of the descriptor of window.event to restore it after event + // dispatching: https://github.com/facebook/react/issues/13688 + var windowEventDescriptor = Object.getOwnPropertyDescriptor( + window, + "event" + ); + // Create an event handler for our fake event. We will synchronously // dispatch our fake event using `dispatchEvent`. Inside the handler, we // call the user-provided callback. @@ -239,6 +246,10 @@ var invokeGuardedCallbackImpl = function( evt.initEvent(evtType, false, false); fakeNode.dispatchEvent(evt); + if (windowEventDescriptor) { + Object.defineProperty(window, "event", windowEventDescriptor); + } + if (didError) { if (!didSetError) { // The callback errored, but the error event never fired. @@ -606,31 +617,77 @@ var warningWithoutStack = function() {}; "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 _console; - - var stringArgs = args.map(function(item) { - return "" + item; - }); - (_console = console).error.apply( - _console, - ["Warning: " + format].concat(stringArgs) - ); + var _args$map = args.map(function(item) { + return "" + item; + }), + a = _args$map[0], + b = _args$map[1], + c = _args$map[2], + d = _args$map[3], + e = _args$map[4], + f = _args$map[5], + g = _args$map[6], + h = _args$map[7]; + + var message = "Warning: " + format; + + // We intentionally don't use spread (or .apply) because it breaks IE9: + // https://github.com/facebook/react/issues/13610 + switch (args.length) { + case 0: + console.error(message); + break; + case 1: + console.error(message, a); + break; + case 2: + console.error(message, a, b); + break; + case 3: + console.error(message, a, b, c); + break; + case 4: + console.error(message, a, b, c, d); + break; + case 5: + console.error(message, a, b, c, d, e); + break; + case 6: + console.error(message, a, b, c, d, e, f); + break; + case 7: + console.error(message, a, b, c, d, e, f, g); + break; + case 8: + console.error(message, a, b, c, d, e, f, g, h); + break; + default: + throw new Error( + "warningWithoutStack() currently supports at most 8 arguments." + ); + } } 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 = + var _message = "Warning: " + format.replace(/%s/g, function() { return args[argIndex++]; }); - throw new Error(message); + throw new Error(_message); } catch (x) {} }; } @@ -1075,11 +1132,11 @@ function runExtractedEventsInBatch( runEventsInBatch(events, false); } -var FunctionalComponent = 0; -var FunctionalComponentLazy = 1; +var FunctionComponent = 0; +var FunctionComponentLazy = 1; var ClassComponent = 2; var ClassComponentLazy = 3; -var IndeterminateComponent = 4; // Before we know whether it is functional or class +var IndeterminateComponent = 4; // Before we know whether it is function or class var HostRoot = 5; // Root of a host tree. Could be nested inside another node. var HostPortal = 6; // A subtree. Could be an entry point to a different renderer. var HostComponent = 7; @@ -1092,6 +1149,8 @@ var ForwardRef = 13; var ForwardRefLazy = 14; var Profiler = 15; var PlaceholderComponent = 16; +var PureComponent = 17; +var PureComponentLazy = 18; function getParent(inst) { do { @@ -2591,13 +2650,16 @@ var REACT_STRICT_MODE_TYPE = hasSymbol var REACT_PROFILER_TYPE = hasSymbol ? Symbol.for("react.profiler") : 0xead2; var REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for("react.provider") : 0xeacd; var REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for("react.context") : 0xeace; -var REACT_ASYNC_MODE_TYPE = hasSymbol ? Symbol.for("react.async_mode") : 0xeacf; +var REACT_CONCURRENT_MODE_TYPE = hasSymbol + ? Symbol.for("react.concurrent_mode") + : 0xeacf; var REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for("react.forward_ref") : 0xead0; var REACT_PLACEHOLDER_TYPE = hasSymbol ? Symbol.for("react.placeholder") : 0xead1; +var REACT_PURE_TYPE = hasSymbol ? Symbol.for("react.pure") : 0xead3; var MAYBE_ITERATOR_SYMBOL = typeof Symbol === "function" && Symbol.iterator; var FAUX_ITERATOR_SYMBOL = "@@iterator"; @@ -2648,8 +2710,8 @@ function getComponentName(type) { return type; } switch (type) { - case REACT_ASYNC_MODE_TYPE: - return "AsyncMode"; + case REACT_CONCURRENT_MODE_TYPE: + return "ConcurrentMode"; case REACT_FRAGMENT_TYPE: return "Fragment"; case REACT_PORTAL_TYPE: @@ -2670,9 +2732,12 @@ function getComponentName(type) { case REACT_FORWARD_REF_TYPE: var renderFn = type.render; var functionName = renderFn.displayName || renderFn.name || ""; - return functionName !== "" - ? "ForwardRef(" + functionName + ")" - : "ForwardRef"; + return ( + type.displayName || + (functionName !== "" + ? "ForwardRef(" + functionName + ")" + : "ForwardRef") + ); } if (typeof type.then === "function") { var thenable = type; @@ -3673,10 +3738,6 @@ function _classCallCheck(instance, Constructor) { // This means that they never overlap. var nextReactTag = 2; -/* eslint-disable no-use-before-define */ - -/* eslint-enable no-use-before-define */ - // TODO: Remove this conditional once all changes have propagated. if (FabricUIManager.registerEventHandler) { /** @@ -4001,8 +4062,8 @@ var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame; function describeFiber(fiber) { switch (fiber.tag) { case IndeterminateComponent: - case FunctionalComponent: - case FunctionalComponentLazy: + case FunctionComponent: + case FunctionComponentLazy: case ClassComponent: case ClassComponentLazy: case HostComponent: @@ -4083,13 +4144,11 @@ function setCurrentPhase(lifeCyclePhase) { var debugRenderPhaseSideEffects = false; var debugRenderPhaseSideEffectsForStrictMode = false; var enableUserTimingAPI = true; -var enableGetDerivedStateFromCatch = false; var enableSuspense = false; var warnAboutDeprecatedLifecycles = false; -var warnAboutLegacyContextAPI = false; var replayFailedUnitOfWorkWithInvokeGuardedCallback = true; var enableProfilerTimer = true; -var enableSchedulerTracking = true; +var enableSchedulerTracing = true; // Only used in www builds. @@ -5041,7 +5100,7 @@ function computeInteractiveExpiration(currentTime) { } var NoContext = 0; -var AsyncMode = 1; +var ConcurrentMode = 1; var StrictMode = 2; var ProfileMode = 4; @@ -5153,13 +5212,15 @@ function resolveLazyComponentTag(fiber, Component) { if (typeof Component === "function") { return shouldConstruct(Component) ? ClassComponentLazy - : FunctionalComponentLazy; - } else if ( - Component !== undefined && - Component !== null && - Component.$$typeof - ) { - return ForwardRefLazy; + : FunctionComponentLazy; + } else if (Component !== undefined && Component !== null) { + var $$typeof = Component.$$typeof; + if ($$typeof === REACT_FORWARD_REF_TYPE) { + return ForwardRefLazy; + } + if ($$typeof === REACT_PURE_TYPE) { + return PureComponentLazy; + } } return IndeterminateComponent; } @@ -5213,15 +5274,8 @@ function createWorkInProgress(current, pendingProps, expirationTime) { } } - // Don't touching the subtree's expiration time, which has not changed. workInProgress.childExpirationTime = current.childExpirationTime; - if (pendingProps !== current.pendingProps) { - // This fiber has new props. - workInProgress.expirationTime = expirationTime; - } else { - // This fiber's props have not changed. - workInProgress.expirationTime = current.expirationTime; - } + workInProgress.expirationTime = current.expirationTime; workInProgress.child = current.child; workInProgress.memoizedProps = current.memoizedProps; @@ -5242,8 +5296,8 @@ function createWorkInProgress(current, pendingProps, expirationTime) { return workInProgress; } -function createHostRootFiber(isAsync) { - var mode = isAsync ? AsyncMode | StrictMode : NoContext; +function createHostRootFiber(isConcurrent) { + var mode = isConcurrent ? ConcurrentMode | StrictMode : NoContext; if (enableProfilerTimer && isDevToolsPresent) { // Always collect profile timings when DevTools are present. @@ -5280,9 +5334,9 @@ function createFiberFromElement(element, mode, expirationTime) { expirationTime, key ); - case REACT_ASYNC_MODE_TYPE: + case REACT_CONCURRENT_MODE_TYPE: fiberTag = Mode; - mode |= AsyncMode | StrictMode; + mode |= ConcurrentMode | StrictMode; break; case REACT_STRICT_MODE_TYPE: fiberTag = Mode; @@ -5306,6 +5360,9 @@ function createFiberFromElement(element, mode, expirationTime) { case REACT_FORWARD_REF_TYPE: fiberTag = ForwardRef; break getTag; + case REACT_PURE_TYPE: + fiberTag = PureComponent; + break getTag; default: { if (typeof type.then === "function") { fiberTag = IndeterminateComponent; @@ -5455,29 +5512,26 @@ function assignFiberPropertiesInDEV(target, source) { return target; } -/* eslint-disable no-use-before-define */ // TODO: This should be lifted into the renderer. -// The following attributes are only used by interaction tracking builds. +// The following attributes are only used by interaction tracing builds. // They enable interactions to be associated with their async work, // And expose interaction metadata to the React DevTools Profiler plugin. -// Note that these attributes are only defined when the enableSchedulerTracking flag is enabled. +// Note that these attributes are only defined when the enableSchedulerTracing flag is enabled. // Exported FiberRoot type includes all properties, // To avoid requiring potentially error-prone :any casts throughout the project. -// Profiling properties are only safe to access in profiling builds (when enableSchedulerTracking is true). +// Profiling properties are only safe to access in profiling builds (when enableSchedulerTracing is true). // The types are defined separately within this file to ensure they stay in sync. -// (We don't have to use an inline :any cast when enableSchedulerTracking is disabled.) - -/* eslint-enable no-use-before-define */ +// (We don't have to use an inline :any cast when enableSchedulerTracing is disabled.) -function createFiberRoot(containerInfo, isAsync, hydrate) { +function createFiberRoot(containerInfo, isConcurrent, hydrate) { // Cyclic construction. This cheats the type system right now because // stateNode is any. - var uninitializedFiber = createHostRootFiber(isAsync); + var uninitializedFiber = createHostRootFiber(isConcurrent); var root = void 0; - if (enableSchedulerTracking) { + if (enableSchedulerTracing) { root = { current: uninitializedFiber, containerInfo: containerInfo, @@ -5502,7 +5556,7 @@ function createFiberRoot(containerInfo, isAsync, hydrate) { firstBatch: null, nextScheduledRoot: null, - interactionThreadID: tracking.unstable_getThreadID(), + interactionThreadID: tracing.unstable_getThreadID(), memoizedInteractions: new Set(), pendingInteractionMap: new Map() }; @@ -5536,8 +5590,8 @@ function createFiberRoot(containerInfo, isAsync, hydrate) { uninitializedFiber.stateNode = root; // The reason for the way the Flow types are structured in this file, - // Is to avoid needing :any casts everywhere interaction tracking fields are used. - // Unfortunately that requires an :any cast for non-interaction tracking capable builds. + // Is to avoid needing :any casts everywhere interaction tracing fields are used. + // Unfortunately that requires an :any cast for non-interaction tracing capable builds. // $FlowFixMe Remove this :any cast and replace it with something better. return root; } @@ -7268,7 +7322,7 @@ function shallowEqual(objA, objB) { } var fakeInternalInstance = {}; -var isArray = Array.isArray; +var isArray$1 = Array.isArray; // React.Component uses a shared frozen object by default. // We'll use it to determine whether we need to initialize legacy refs. @@ -7282,6 +7336,8 @@ var didWarnAboutUndefinedDerivedState = void 0; var warnOnUndefinedDerivedState = void 0; var warnOnInvalidCallback = void 0; var didWarnAboutDirectlyAssigningPropsToState = void 0; +var didWarnAboutContextTypeAndContextTypes = void 0; +var didWarnAboutInvalidateContextType = void 0; { didWarnAboutStateAssignmentForComponent = new Set(); @@ -7290,6 +7346,8 @@ var didWarnAboutDirectlyAssigningPropsToState = void 0; didWarnAboutLegacyLifecyclesAndDerivedState = new Set(); didWarnAboutDirectlyAssigningPropsToState = new Set(); didWarnAboutUndefinedDerivedState = new Set(); + didWarnAboutContextTypeAndContextTypes = new Set(); + didWarnAboutInvalidateContextType = new Set(); var didWarnOnInvalidCallback = new Set(); @@ -7451,7 +7509,7 @@ function checkShouldComponentUpdate( newProps, oldState, newState, - nextLegacyContext + nextContext ) { var instance = workInProgress.stateNode; if (typeof instance.shouldComponentUpdate === "function") { @@ -7459,7 +7517,7 @@ function checkShouldComponentUpdate( var shouldUpdate = instance.shouldComponentUpdate( newProps, newState, - nextLegacyContext + nextContext ); stopPhaseTimer(); @@ -7544,6 +7602,15 @@ function checkClassInstance(workInProgress, ctor, newProps) { 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; var noInstanceContextTypes = !instance.contextTypes; !noInstanceContextTypes ? warningWithoutStack$1( @@ -7553,6 +7620,21 @@ function checkClassInstance(workInProgress, ctor, newProps) { name ) : void 0; + + if ( + ctor.contextType && + ctor.contextTypes && + !didWarnAboutContextTypeAndContextTypes.has(ctor) + ) { + didWarnAboutContextTypeAndContextTypes.add(ctor); + warningWithoutStack$1( + false, + "%s declares both contextTypes and contextType static properties. " + + "The legacy contextTypes property will be ignored.", + name + ); + } + var noComponentShouldUpdate = typeof instance.componentShouldUpdate !== "function"; !noComponentShouldUpdate @@ -7668,11 +7750,11 @@ function checkClassInstance(workInProgress, ctor, newProps) { ) : void 0; var noInstanceGetDerivedStateFromCatch = - typeof instance.getDerivedStateFromCatch !== "function"; + typeof instance.getDerivedStateFromError !== "function"; !noInstanceGetDerivedStateFromCatch ? warningWithoutStack$1( false, - "%s: getDerivedStateFromCatch() is defined as an instance method " + + "%s: getDerivedStateFromError() is defined as an instance method " + "and will be ignored. Instead, declare it as a static method.", name ) @@ -7688,7 +7770,7 @@ function checkClassInstance(workInProgress, ctor, newProps) { ) : void 0; var _state = instance.state; - if (_state && (typeof _state !== "object" || isArray(_state))) { + if (_state && (typeof _state !== "object" || isArray$1(_state))) { warningWithoutStack$1( false, "%s.state: must be set to an object or null", @@ -7724,12 +7806,37 @@ function constructClassInstance( props, renderExpirationTime ) { - var unmaskedContext = getUnmaskedContext(workInProgress, ctor, true); - var contextTypes = ctor.contextTypes; - var isContextConsumer = contextTypes !== null && contextTypes !== undefined; - var context = isContextConsumer - ? getMaskedContext(workInProgress, unmaskedContext) - : emptyContextObject; + var isLegacyContextConsumer = false; + var unmaskedContext = emptyContextObject; + var context = null; + var contextType = ctor.contextType; + if (typeof contextType === "object" && contextType !== null) { + { + if ( + typeof contextType.unstable_read !== "function" && + !didWarnAboutInvalidateContextType.has(ctor) + ) { + didWarnAboutInvalidateContextType.add(ctor); + warningWithoutStack$1( + false, + "%s defines an invalid contextType. " + + "contextType should point to the Context object returned by React.createContext(). " + + "Did you accidentally pass the Context.Provider instead?", + getComponentName(ctor) || "Component" + ); + } + } + + context = contextType.unstable_read(); + } else { + unmaskedContext = getUnmaskedContext(workInProgress, ctor, true); + var contextTypes = ctor.contextTypes; + isLegacyContextConsumer = + contextTypes !== null && contextTypes !== undefined; + context = isLegacyContextConsumer + ? getMaskedContext(workInProgress, unmaskedContext) + : emptyContextObject; + } // Instantiate twice to help detect side-effects. { @@ -7836,7 +7943,7 @@ function constructClassInstance( // Cache unmasked context so we can avoid recreating masked context unless necessary. // ReactFiberContext usually updates this cache but can't for newly-created instances. - if (isContextConsumer) { + if (isLegacyContextConsumer) { cacheContext(workInProgress, unmaskedContext, context); } @@ -7874,15 +7981,15 @@ function callComponentWillReceiveProps( workInProgress, instance, newProps, - nextLegacyContext + nextContext ) { var oldState = instance.state; startPhaseTimer(workInProgress, "componentWillReceiveProps"); if (typeof instance.componentWillReceiveProps === "function") { - instance.componentWillReceiveProps(newProps, nextLegacyContext); + instance.componentWillReceiveProps(newProps, nextContext); } if (typeof instance.UNSAFE_componentWillReceiveProps === "function") { - instance.UNSAFE_componentWillReceiveProps(newProps, nextLegacyContext); + instance.UNSAFE_componentWillReceiveProps(newProps, nextContext); } stopPhaseTimer(); @@ -7916,12 +8023,17 @@ function mountClassInstance( } var instance = workInProgress.stateNode; - var unmaskedContext = getUnmaskedContext(workInProgress, ctor, true); - instance.props = newProps; instance.state = workInProgress.memoizedState; instance.refs = emptyRefsObject; - instance.context = getMaskedContext(workInProgress, unmaskedContext); + + var contextType = ctor.contextType; + if (typeof contextType === "object" && contextType !== null) { + instance.context = contextType.unstable_read(); + } else { + var unmaskedContext = getUnmaskedContext(workInProgress, ctor, true); + instance.context = getMaskedContext(workInProgress, unmaskedContext); + } { if (instance.state === newProps) { @@ -8022,15 +8134,18 @@ function resumeMountClassInstance( instance.props = oldProps; var oldContext = instance.context; - var nextLegacyUnmaskedContext = getUnmaskedContext( - workInProgress, - ctor, - true - ); - var nextLegacyContext = getMaskedContext( - workInProgress, - nextLegacyUnmaskedContext - ); + var contextType = ctor.contextType; + var nextContext = void 0; + if (typeof contextType === "object" && contextType !== null) { + nextContext = contextType.unstable_read(); + } else { + var nextLegacyUnmaskedContext = getUnmaskedContext( + workInProgress, + ctor, + true + ); + nextContext = getMaskedContext(workInProgress, nextLegacyUnmaskedContext); + } var getDerivedStateFromProps = ctor.getDerivedStateFromProps; var hasNewLifecycles = @@ -8048,12 +8163,12 @@ function resumeMountClassInstance( (typeof instance.UNSAFE_componentWillReceiveProps === "function" || typeof instance.componentWillReceiveProps === "function") ) { - if (oldProps !== newProps || oldContext !== nextLegacyContext) { + if (oldProps !== newProps || oldContext !== nextContext) { callComponentWillReceiveProps( workInProgress, instance, newProps, - nextLegacyContext + nextContext ); } } @@ -8106,7 +8221,7 @@ function resumeMountClassInstance( newProps, oldState, newState, - nextLegacyContext + nextContext ); if (shouldUpdate) { @@ -8146,7 +8261,7 @@ function resumeMountClassInstance( // if shouldComponentUpdate returns false. instance.props = newProps; instance.state = newState; - instance.context = nextLegacyContext; + instance.context = nextContext; return shouldUpdate; } @@ -8165,15 +8280,14 @@ function updateClassInstance( instance.props = oldProps; var oldContext = instance.context; - var nextLegacyUnmaskedContext = getUnmaskedContext( - workInProgress, - ctor, - true - ); - var nextLegacyContext = getMaskedContext( - workInProgress, - nextLegacyUnmaskedContext - ); + var contextType = ctor.contextType; + var nextContext = void 0; + if (typeof contextType === "object" && contextType !== null) { + nextContext = contextType.unstable_read(); + } else { + var nextUnmaskedContext = getUnmaskedContext(workInProgress, ctor, true); + nextContext = getMaskedContext(workInProgress, nextUnmaskedContext); + } var getDerivedStateFromProps = ctor.getDerivedStateFromProps; var hasNewLifecycles = @@ -8191,12 +8305,12 @@ function updateClassInstance( (typeof instance.UNSAFE_componentWillReceiveProps === "function" || typeof instance.componentWillReceiveProps === "function") ) { - if (oldProps !== newProps || oldContext !== nextLegacyContext) { + if (oldProps !== newProps || oldContext !== nextContext) { callComponentWillReceiveProps( workInProgress, instance, newProps, - nextLegacyContext + nextContext ); } } @@ -8263,7 +8377,7 @@ function updateClassInstance( newProps, oldState, newState, - nextLegacyContext + nextContext ); if (shouldUpdate) { @@ -8276,14 +8390,10 @@ function updateClassInstance( ) { startPhaseTimer(workInProgress, "componentWillUpdate"); if (typeof instance.componentWillUpdate === "function") { - instance.componentWillUpdate(newProps, newState, nextLegacyContext); + instance.componentWillUpdate(newProps, newState, nextContext); } if (typeof instance.UNSAFE_componentWillUpdate === "function") { - instance.UNSAFE_componentWillUpdate( - newProps, - newState, - nextLegacyContext - ); + instance.UNSAFE_componentWillUpdate(newProps, newState, nextContext); } stopPhaseTimer(); } @@ -8323,7 +8433,7 @@ function updateClassInstance( // if shouldComponentUpdate returns false. instance.props = newProps; instance.state = newState; - instance.context = nextLegacyContext; + instance.context = nextContext; return shouldUpdate; } @@ -8381,7 +8491,7 @@ var warnForMissingKey = function(child) {}; }; } -var isArray$1 = Array.isArray; +var isArray = Array.isArray; function coerceRef(returnFiber, current$$1, element) { var mixedRef = element.ref; @@ -8418,7 +8528,7 @@ function coerceRef(returnFiber, current$$1, element) { invariant( ownerFiber.tag === ClassComponent || ownerFiber.tag === ClassComponentLazy, - "Stateless function components cannot have refs." + "Function components cannot have refs." ); inst = ownerFiber.stateNode; } @@ -8461,7 +8571,7 @@ function coerceRef(returnFiber, current$$1, element) { element._owner, "Element ref was specified as a string (%s) but no owner was set. This could happen for one of" + " the following reasons:\n" + - "1. You may be adding a ref to a functional component\n" + + "1. You may be adding a ref to a function component\n" + "2. You may be adding a ref to a component that was not created inside a component's render method\n" + "3. You have multiple copies of React loaded\n" + "See https://fb.me/react-refs-must-have-owner for more information.", @@ -8749,7 +8859,7 @@ function ChildReconciler(shouldTrackSideEffects) { } } - if (isArray$1(newChild) || getIteratorFn(newChild)) { + if (isArray(newChild) || getIteratorFn(newChild)) { var _created3 = createFiberFromFragment( newChild, returnFiber.mode, @@ -8829,7 +8939,7 @@ function ChildReconciler(shouldTrackSideEffects) { } } - if (isArray$1(newChild) || getIteratorFn(newChild)) { + if (isArray(newChild) || getIteratorFn(newChild)) { if (key !== null) { return null; } @@ -8911,7 +9021,7 @@ function ChildReconciler(shouldTrackSideEffects) { } } - if (isArray$1(newChild) || getIteratorFn(newChild)) { + if (isArray(newChild) || getIteratorFn(newChild)) { var _matchedFiber3 = existingChildren.get(newIdx) || null; return updateFragment( returnFiber, @@ -9526,7 +9636,7 @@ function ChildReconciler(shouldTrackSideEffects) { ); } - if (isArray$1(newChild)) { + if (isArray(newChild)) { return reconcileChildrenArray( returnFiber, currentFirstChild, @@ -9571,7 +9681,7 @@ function ChildReconciler(shouldTrackSideEffects) { // Intentionally fall through to the next case, which handles both // functions and classes // eslint-disable-next-lined no-fallthrough - case FunctionalComponent: { + case FunctionComponent: { var Component = returnFiber.type; invariant( false, @@ -9988,13 +10098,15 @@ function readLazyComponentType(thenable) { var ReactCurrentOwner$3 = ReactSharedInternals.ReactCurrentOwner; var didWarnAboutBadClass = void 0; -var didWarnAboutGetDerivedStateOnFunctionalComponent = void 0; -var didWarnAboutStatelessRefs = void 0; +var didWarnAboutContextTypeOnFunctionComponent = void 0; +var didWarnAboutGetDerivedStateOnFunctionComponent = void 0; +var didWarnAboutFunctionRefs = void 0; { didWarnAboutBadClass = {}; - didWarnAboutGetDerivedStateOnFunctionalComponent = {}; - didWarnAboutStatelessRefs = {}; + didWarnAboutContextTypeOnFunctionComponent = {}; + didWarnAboutGetDerivedStateOnFunctionComponent = {}; + didWarnAboutFunctionRefs = {}; } function reconcileChildren( @@ -10030,6 +10142,38 @@ function reconcileChildren( } } +function forceUnmountCurrentAndReconcile( + current$$1, + workInProgress, + nextChildren, + renderExpirationTime +) { + // This function is fork of reconcileChildren. It's used in cases where we + // want to reconcile without matching against the existing set. This has the + // effect of all current children being unmounted; even if the type and key + // are the same, the old child is unmounted and a new child is created. + // + // To do this, we're going to go through the reconcile algorithm twice. In + // the first pass, we schedule a deletion for all the current children by + // passing null. + workInProgress.child = reconcileChildFibers( + workInProgress, + current$$1.child, + null, + 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. + workInProgress.child = reconcileChildFibers( + workInProgress, + null, + nextChildren, + renderExpirationTime + ); +} + function updateForwardRef( current$$1, workInProgress, @@ -10071,6 +10215,56 @@ function updateForwardRef( return workInProgress.child; } +function updatePureComponent( + current$$1, + workInProgress, + Component, + nextProps, + updateExpirationTime, + renderExpirationTime +) { + var render = Component.render; + + if ( + current$$1 !== null && + (updateExpirationTime === NoWork || + updateExpirationTime > renderExpirationTime) + ) { + var prevProps = current$$1.memoizedProps; + // Default to shallow comparison + var compare = Component.compare; + compare = compare !== null ? compare : shallowEqual; + if (compare(prevProps, nextProps)) { + return bailoutOnAlreadyFinishedWork( + current$$1, + workInProgress, + renderExpirationTime + ); + } + } + + // The rest is a fork of updateFunctionComponent + var nextChildren = void 0; + prepareToReadContext(workInProgress, renderExpirationTime); + { + ReactCurrentOwner$3.current = workInProgress; + setCurrentPhase("render"); + nextChildren = render(nextProps); + setCurrentPhase(null); + } + + // React DevTools reads this flag. + workInProgress.effectTag |= PerformedWork; + reconcileChildren( + current$$1, + workInProgress, + nextChildren, + renderExpirationTime + ); + memoizeProps(workInProgress, nextProps); + return workInProgress.child; +} + function updateFragment(current$$1, workInProgress, renderExpirationTime) { var nextChildren = workInProgress.pendingProps; reconcileChildren( @@ -10122,7 +10316,7 @@ function markRef(current$$1, workInProgress) { } } -function updateFunctionalComponent( +function updateFunctionComponent( current$$1, workInProgress, Component, @@ -10250,8 +10444,7 @@ function finishClassComponent( var nextChildren = void 0; if ( didCaptureError && - (!enableGetDerivedStateFromCatch || - typeof Component.getDerivedStateFromCatch !== "function") + typeof Component.getDerivedStateFromError !== "function" ) { // If we captured an error, but getDerivedStateFrom catch is not defined, // unmount all the children. componentDidCatch will schedule an update to @@ -10281,20 +10474,25 @@ function finishClassComponent( // React DevTools reads this flag. workInProgress.effectTag |= PerformedWork; if (current$$1 !== null && didCaptureError) { - // If we're recovering from an error, reconcile twice: first to delete - // all the existing children. - reconcileChildren(current$$1, workInProgress, null, renderExpirationTime); - workInProgress.child = null; - // Now we can continue reconciling like normal. This has the effect of - // remounting all children regardless of whether their their - // identity matches. + // If we're recovering from an error, reconcile without reusing any of + // the existing children. Conceptually, the normal children and the children + // that are shown on error are two different sets, so we shouldn't reuse + // normal children even if their identities match. + forceUnmountCurrentAndReconcile( + current$$1, + workInProgress, + nextChildren, + renderExpirationTime + ); + } else { + reconcileChildren( + current$$1, + workInProgress, + nextChildren, + renderExpirationTime + ); } - reconcileChildren( - current$$1, - workInProgress, - nextChildren, - renderExpirationTime - ); + // Memoize props and state using the values we just used to render. // TODO: Restructure so we never read values from the instance. memoizeState(workInProgress, instance.state); @@ -10427,7 +10625,7 @@ function updateHostComponent(current$$1, workInProgress, renderExpirationTime) { // Check the host config to see if the children are offscreen/hidden. if ( renderExpirationTime !== Never && - workInProgress.mode & AsyncMode && + workInProgress.mode & ConcurrentMode && shouldDeprioritizeSubtree(type, nextProps) ) { // Schedule this fiber to re-render at offscreen priority. Then bailout. @@ -10476,6 +10674,7 @@ function mountIndeterminateComponent( current$$1, workInProgress, Component, + updateExpirationTime, renderExpirationTime ) { invariant( @@ -10496,37 +10695,53 @@ function mountIndeterminateComponent( Component )); var resolvedProps = resolveDefaultProps(Component, props); + var child = void 0; switch (resolvedTag) { - case FunctionalComponentLazy: { - return updateFunctionalComponent( + case FunctionComponentLazy: { + child = updateFunctionComponent( current$$1, workInProgress, Component, resolvedProps, renderExpirationTime ); + break; } case ClassComponentLazy: { - return updateClassComponent( + child = updateClassComponent( current$$1, workInProgress, Component, resolvedProps, renderExpirationTime ); + break; } case ForwardRefLazy: { - return updateForwardRef( + child = updateForwardRef( current$$1, workInProgress, Component, resolvedProps, renderExpirationTime ); + break; + } + case PureComponentLazy: { + child = updatePureComponent( + current$$1, + workInProgress, + Component, + resolvedProps, + updateExpirationTime, + renderExpirationTime + ); + break; } default: { - // This message intentionally doesn't metion ForwardRef because the - // fact that it's a separate type of work is an implementation detail. + // This message intentionally doesn't metion ForwardRef or PureComponent + // because the fact that it's a separate type of work is an + // implementation detail. invariant( false, "Element type is invalid. Received a promise that resolves to: %s. " + @@ -10535,6 +10750,8 @@ function mountIndeterminateComponent( ); } } + workInProgress.memoizedProps = props; + return child; } var unmaskedContext = getUnmaskedContext(workInProgress, Component, false); @@ -10617,14 +10834,14 @@ function mountIndeterminateComponent( renderExpirationTime ); } else { - // Proceed under the assumption that this is a functional component - workInProgress.tag = FunctionalComponent; + // Proceed under the assumption that this is a function component + workInProgress.tag = FunctionComponent; { if (Component) { !!Component.childContextTypes ? warningWithoutStack$1( false, - "%s(...): childContextTypes cannot be defined on a functional component.", + "%s(...): childContextTypes cannot be defined on a function component.", Component.displayName || Component.name || "Component" ) : void 0; @@ -10641,11 +10858,11 @@ function mountIndeterminateComponent( if (debugSource) { warningKey = debugSource.fileName + ":" + debugSource.lineNumber; } - if (!didWarnAboutStatelessRefs[warningKey]) { - didWarnAboutStatelessRefs[warningKey] = true; + if (!didWarnAboutFunctionRefs[warningKey]) { + didWarnAboutFunctionRefs[warningKey] = true; warning$1( false, - "Stateless function components cannot be given refs. " + + "Function components cannot be given refs. " + "Attempts to access this ref will fail.%s", info ); @@ -10655,15 +10872,29 @@ function mountIndeterminateComponent( if (typeof Component.getDerivedStateFromProps === "function") { var _componentName = getComponentName(Component) || "Unknown"; - if (!didWarnAboutGetDerivedStateOnFunctionalComponent[_componentName]) { + if (!didWarnAboutGetDerivedStateOnFunctionComponent[_componentName]) { warningWithoutStack$1( false, - "%s: Stateless functional components do not support getDerivedStateFromProps.", + "%s: Function components do not support getDerivedStateFromProps.", _componentName ); - didWarnAboutGetDerivedStateOnFunctionalComponent[ - _componentName - ] = true; + didWarnAboutGetDerivedStateOnFunctionComponent[_componentName] = true; + } + } + + if ( + typeof Component.contextType === "object" && + Component.contextType !== null + ) { + var _componentName2 = getComponentName(Component) || "Unknown"; + + if (!didWarnAboutContextTypeOnFunctionComponent[_componentName2]) { + warningWithoutStack$1( + false, + "%s: Function components do not support contextType.", + _componentName2 + ); + didWarnAboutContextTypeOnFunctionComponent[_componentName2] = true; } } } @@ -10691,13 +10922,6 @@ function updatePlaceholderComponent( // suspended during the last commit. Switch to the placholder. workInProgress.updateQueue = null; nextDidTimeout = true; - // If we're recovering from an error, reconcile twice: first to delete - // all the existing children. - reconcileChildren(current$$1, workInProgress, null, renderExpirationTime); - current$$1.child = null; - // Now we can continue reconciling like normal. This has the effect of - // remounting all children regardless of whether their their - // identity matches. } else { nextDidTimeout = !alreadyCaptured; } @@ -10724,14 +10948,31 @@ function updatePlaceholderComponent( nextChildren = nextDidTimeout ? nextProps.fallback : children; } + if ( + current$$1 !== null && + nextDidTimeout !== workInProgress.memoizedState + ) { + // We're about to switch from the placeholder children to the normal + // children, or vice versa. These are two different conceptual sets that + // happen to be stored in the same set. Call this special function to + // force the new set not to match with the current set. + // TODO: The proper way to model this is by storing each set separately. + forceUnmountCurrentAndReconcile( + current$$1, + workInProgress, + nextChildren, + renderExpirationTime + ); + } else { + reconcileChildren( + current$$1, + workInProgress, + nextChildren, + renderExpirationTime + ); + } workInProgress.memoizedProps = nextProps; workInProgress.memoizedState = nextDidTimeout; - reconcileChildren( - current$$1, - workInProgress, - nextChildren, - renderExpirationTime - ); return workInProgress.child; } else { return null; @@ -10944,59 +11185,65 @@ function memoizeState(workInProgress, nextState) { function beginWork(current$$1, workInProgress, renderExpirationTime) { var updateExpirationTime = workInProgress.expirationTime; - if ( - !hasContextChanged() && - (updateExpirationTime === NoWork || - updateExpirationTime > renderExpirationTime) - ) { - // This fiber does not have any pending work. Bailout without entering - // the begin phase. There's still some bookkeeping we that needs to be done - // in this optimized path, mostly pushing stuff onto the stack. - switch (workInProgress.tag) { - case HostRoot: - pushHostRootContext(workInProgress); - resetHydrationState(); - break; - case HostComponent: - pushHostContext(workInProgress); - break; - case ClassComponent: { - var Component = workInProgress.type; - if (isContextProvider(Component)) { - pushContextProvider(workInProgress); + + if (current$$1 !== null) { + var oldProps = current$$1.memoizedProps; + var newProps = workInProgress.pendingProps; + if ( + oldProps === newProps && + !hasContextChanged() && + (updateExpirationTime === NoWork || + updateExpirationTime > renderExpirationTime) + ) { + // This fiber does not have any pending work. Bailout without entering + // the begin phase. There's still some bookkeeping we that needs to be done + // in this optimized path, mostly pushing stuff onto the stack. + switch (workInProgress.tag) { + case HostRoot: + pushHostRootContext(workInProgress); + resetHydrationState(); + break; + case HostComponent: + pushHostContext(workInProgress); + break; + case ClassComponent: { + var Component = workInProgress.type; + if (isContextProvider(Component)) { + pushContextProvider(workInProgress); + } + break; } - break; - } - case ClassComponentLazy: { - var thenable = workInProgress.type; - var _Component = getResultFromResolvedThenable(thenable); - if (isContextProvider(_Component)) { - pushContextProvider(workInProgress); + case ClassComponentLazy: { + var thenable = workInProgress.type; + var _Component = getResultFromResolvedThenable(thenable); + if (isContextProvider(_Component)) { + pushContextProvider(workInProgress); + } + break; } - break; - } - case HostPortal: - pushHostContainer( - workInProgress, - workInProgress.stateNode.containerInfo - ); - break; - case ContextProvider: { - var newValue = workInProgress.memoizedProps.value; - pushProvider(workInProgress, newValue); - break; - } - case Profiler: - if (enableProfilerTimer) { - workInProgress.effectTag |= Update; + case HostPortal: + pushHostContainer( + workInProgress, + workInProgress.stateNode.containerInfo + ); + break; + case ContextProvider: { + var newValue = workInProgress.memoizedProps.value; + pushProvider(workInProgress, newValue); + break; } - break; + case Profiler: + if (enableProfilerTimer) { + workInProgress.effectTag |= Update; + } + break; + } + return bailoutOnAlreadyFinishedWork( + current$$1, + workInProgress, + renderExpirationTime + ); } - return bailoutOnAlreadyFinishedWork( - current$$1, - workInProgress, - renderExpirationTime - ); } // Before entering the begin phase, clear the expiration time. @@ -11004,63 +11251,64 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { switch (workInProgress.tag) { case IndeterminateComponent: { - var _Component3 = workInProgress.type; + var _Component2 = workInProgress.type; return mountIndeterminateComponent( current$$1, workInProgress, - _Component3, + _Component2, + updateExpirationTime, renderExpirationTime ); } - case FunctionalComponent: { - var _Component4 = workInProgress.type; - var _unresolvedProps = workInProgress.pendingProps; - return updateFunctionalComponent( + case FunctionComponent: { + var _Component3 = workInProgress.type; + var unresolvedProps = workInProgress.pendingProps; + return updateFunctionComponent( current$$1, workInProgress, - _Component4, - _unresolvedProps, + _Component3, + unresolvedProps, renderExpirationTime ); } - case FunctionalComponentLazy: { - var _thenable2 = workInProgress.type; - var _Component5 = getResultFromResolvedThenable(_thenable2); - var _unresolvedProps2 = workInProgress.pendingProps; - var _child = updateFunctionalComponent( + case FunctionComponentLazy: { + var _thenable = workInProgress.type; + var _Component4 = getResultFromResolvedThenable(_thenable); + var _unresolvedProps = workInProgress.pendingProps; + var child = updateFunctionComponent( current$$1, workInProgress, - _Component5, - resolveDefaultProps(_Component5, _unresolvedProps2), + _Component4, + resolveDefaultProps(_Component4, _unresolvedProps), renderExpirationTime ); - workInProgress.memoizedProps = _unresolvedProps2; - return _child; + workInProgress.memoizedProps = _unresolvedProps; + return child; } case ClassComponent: { - var _Component6 = workInProgress.type; - var _unresolvedProps3 = workInProgress.pendingProps; + var _Component5 = workInProgress.type; + var _unresolvedProps2 = workInProgress.pendingProps; return updateClassComponent( current$$1, workInProgress, - _Component6, - _unresolvedProps3, + _Component5, + _unresolvedProps2, renderExpirationTime ); } case ClassComponentLazy: { - var _thenable3 = workInProgress.type; - var _Component7 = getResultFromResolvedThenable(_thenable3); - var _unresolvedProps4 = workInProgress.pendingProps; - var _child2 = updateClassComponent( + var _thenable2 = workInProgress.type; + var _Component6 = getResultFromResolvedThenable(_thenable2); + var _unresolvedProps3 = workInProgress.pendingProps; + var _child = updateClassComponent( current$$1, workInProgress, - _Component7, - resolveDefaultProps(_Component7, _unresolvedProps4), + _Component6, + resolveDefaultProps(_Component6, _unresolvedProps3), renderExpirationTime ); - workInProgress.memoizedProps = _unresolvedProps4; - return _child2; + workInProgress.memoizedProps = _unresolvedProps3; + return _child; } case HostRoot: return updateHostRoot(current$$1, workInProgress, renderExpirationTime); @@ -11094,19 +11342,20 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { renderExpirationTime ); } - case ForwardRefLazy: - var _thenable = workInProgress.type; - var _Component2 = getResultFromResolvedThenable(_thenable); - var unresolvedProps = workInProgress.pendingProps; - var child = updateForwardRef( + case ForwardRefLazy: { + var _thenable3 = workInProgress.type; + var _Component7 = getResultFromResolvedThenable(_thenable3); + var _unresolvedProps4 = workInProgress.pendingProps; + var _child2 = updateForwardRef( current$$1, workInProgress, - _Component2, - resolveDefaultProps(_Component2, unresolvedProps), + _Component7, + resolveDefaultProps(_Component7, _unresolvedProps4), renderExpirationTime ); - workInProgress.memoizedProps = unresolvedProps; - return child; + workInProgress.memoizedProps = _unresolvedProps4; + return _child2; + } case Fragment: return updateFragment(current$$1, workInProgress, renderExpirationTime); case Mode: @@ -11125,6 +11374,32 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { workInProgress, renderExpirationTime ); + case PureComponent: { + var _type = workInProgress.type; + return updatePureComponent( + current$$1, + workInProgress, + _type, + workInProgress.pendingProps, + updateExpirationTime, + renderExpirationTime + ); + } + case PureComponentLazy: { + var _thenable4 = workInProgress.type; + var _Component8 = getResultFromResolvedThenable(_thenable4); + var _unresolvedProps5 = workInProgress.pendingProps; + var _child3 = updatePureComponent( + current$$1, + workInProgress, + _Component8, + resolveDefaultProps(_Component8, _unresolvedProps5), + updateExpirationTime, + renderExpirationTime + ); + workInProgress.memoizedProps = _unresolvedProps5; + return _child3; + } default: invariant( false, @@ -11390,8 +11665,8 @@ function completeWork(current, workInProgress, renderExpirationTime) { var newProps = workInProgress.pendingProps; switch (workInProgress.tag) { - case FunctionalComponent: - case FunctionalComponentLazy: + case FunctionComponent: + case FunctionComponentLazy: break; case ClassComponent: { var Component = workInProgress.type; @@ -11563,6 +11838,9 @@ function completeWork(current, workInProgress, renderExpirationTime) { break; case ContextConsumer: break; + case PureComponent: + case PureComponentLazy: + break; // Error cases case IndeterminateComponent: invariant( @@ -11927,7 +12205,7 @@ function commitLifeCycles( if (enableProfilerTimer) { var onRender = finishedWork.memoizedProps.onRender; - if (enableSchedulerTracking) { + if (enableSchedulerTracing) { onRender( finishedWork.memoizedProps.id, current$$1 === null ? "mount" : "update", @@ -12496,28 +12774,22 @@ function createRootErrorUpdate(fiber, errorInfo, expirationTime) { function createClassErrorUpdate(fiber, errorInfo, expirationTime) { var update = createUpdate(expirationTime); update.tag = CaptureUpdate; - var getDerivedStateFromCatch = fiber.type.getDerivedStateFromCatch; - if ( - enableGetDerivedStateFromCatch && - typeof getDerivedStateFromCatch === "function" - ) { + var getDerivedStateFromError = fiber.type.getDerivedStateFromError; + if (typeof getDerivedStateFromError === "function") { var error = errorInfo.value; update.payload = function() { - return getDerivedStateFromCatch(error); + return getDerivedStateFromError(error); }; } var inst = fiber.stateNode; if (inst !== null && typeof inst.componentDidCatch === "function") { update.callback = function callback() { - if ( - !enableGetDerivedStateFromCatch || - getDerivedStateFromCatch !== "function" - ) { + if (typeof getDerivedStateFromError !== "function") { // To preserve the preexisting retry behavior of error boundaries, // we keep track of which ones already failed during this batch. // This gets reset before we yield back to the browser. - // TODO: Warn in strict mode if getDerivedStateFromCatch is + // TODO: Warn in strict mode if getDerivedStateFromError is // not defined. markLegacyErrorBoundaryAsFailed(this); } @@ -12527,6 +12799,21 @@ function createClassErrorUpdate(fiber, errorInfo, expirationTime) { this.componentDidCatch(error, { componentStack: stack !== null ? stack : "" }); + { + if (typeof getDerivedStateFromError !== "function") { + // If componentDidCatch is the only error boundary method defined, + // then it needs to call setState to recover from errors. + // If no state update is scheduled then the boundary will swallow the error. + !(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; + } + } }; } return update; @@ -12603,10 +12890,10 @@ function throwException( if (!didTimeout) { // Found the nearest boundary. - // If the boundary is not in async mode, we should not suspend, and + // If the boundary is not in concurrent mode, we should not suspend, and // likewise, when the promise resolves, we should ping synchronously. var pingTime = - (_workInProgress.mode & AsyncMode) === NoEffect + (_workInProgress.mode & ConcurrentMode) === NoEffect ? Sync : renderExpirationTime; @@ -12617,6 +12904,9 @@ function throwException( _workInProgress, pingTime ); + if (enableSchedulerTracing) { + onResolveOrReject = tracing.unstable_wrap(onResolveOrReject); + } thenable.then(onResolveOrReject, onResolveOrReject); // If the boundary is outside of strict mode, we should *not* suspend @@ -12640,9 +12930,9 @@ function throwException( ); sourceFiber.effectTag &= ~Incomplete; if (sourceFiber.tag === IndeterminateComponent) { - // Let's just assume it's a functional component. This fiber will + // Let's just assume it's a function component. This fiber will // be unmounted in the immediate next commit, anyway. - sourceFiber.tag = FunctionalComponent; + sourceFiber.tag = FunctionComponent; } if ( @@ -12655,11 +12945,11 @@ function throwException( sourceFiber.effectTag &= ~LifecycleEffectMask; if (sourceFiber.alternate === null) { // We're about to mount a class component that doesn't have an - // instance. Turn this into a dummy functional component instead, + // instance. Turn this into a dummy function component instead, // to prevent type errors. This is a bit weird but it's an edge // case and we're about to synchronously delete this // component, anyway. - sourceFiber.tag = FunctionalComponent; + sourceFiber.tag = FunctionComponent; sourceFiber.type = NoopComponent; } } @@ -12749,8 +13039,7 @@ function throwException( var instance = workInProgress.stateNode; if ( (workInProgress.effectTag & DidCapture) === NoEffect && - ((typeof ctor.getDerivedStateFromCatch === "function" && - enableGetDerivedStateFromCatch) || + (typeof ctor.getDerivedStateFromError === "function" || (instance !== null && typeof instance.componentDidCatch === "function" && !isAlreadyFailedLegacyErrorBoundary(instance))) @@ -12883,14 +13172,14 @@ var didWarnSetStateChildContext = void 0; var warnAboutUpdateOnUnmounted = void 0; var warnAboutInvalidUpdates = void 0; -if (enableSchedulerTracking) { +if (enableSchedulerTracing) { // Provide explicit error message when production+profiling bundle of e.g. react-dom - // is used with production (non-profiling) bundle of schedule/tracking + // is used with production (non-profiling) bundle of schedule/tracing invariant( - tracking.__interactionsRef != null && - tracking.__interactionsRef.current != null, + tracing.__interactionsRef != null && + tracing.__interactionsRef.current != null, "It is not supported to run the profiling version of a renderer (for example, `react-dom/profiling`) " + - "without also replacing the `schedule/tracking` module with `schedule/tracking-profiling`. " + + "without also replacing the `schedule/tracing` module with `schedule/tracing-profiling`. " + "Your bundler might have a setting for aliasing both modules. " + "Learn more at http://fb.me/react-profiling" ); @@ -12971,10 +13260,6 @@ var legacyErrorBoundariesThatAlreadyFailed = null; // Used for performance tracking. var interruptedBy = null; -// Do not decrement interaction counts in the event of suspense timeouts. -// This would lead to prematurely calling the interaction-complete hook. -var suspenseDidTimeout = false; - var stashedWorkInProgressProperties = void 0; var replayUnitOfWork = void 0; var isReplayingFailedUnitOfWork = void 0; @@ -13184,14 +13469,11 @@ function commitBeforeMutationLifecycles() { function commitAllLifeCycles(finishedRoot, committedExpirationTime) { { ReactStrictModeWarnings.flushPendingUnsafeLifecycleWarnings(); + ReactStrictModeWarnings.flushLegacyContextWarning(); if (warnAboutDeprecatedLifecycles) { ReactStrictModeWarnings.flushPendingDeprecationWarnings(); } - - if (warnAboutLegacyContextAPI) { - ReactStrictModeWarnings.flushLegacyContextWarning(); - } } while (nextEffect !== null) { var effectTag = nextEffect.effectTag; @@ -13272,33 +13554,11 @@ function commitRoot(root, finishedWork) { markCommittedPriorityLevels(root, earliestRemainingTimeBeforeCommit); var prevInteractions = null; - var committedInteractions = enableSchedulerTracking ? [] : null; - if (enableSchedulerTracking) { + if (enableSchedulerTracing) { // Restore any pending interactions at this point, // So that cascading work triggered during the render phase will be accounted for. - prevInteractions = tracking.__interactionsRef.current; - tracking.__interactionsRef.current = root.memoizedInteractions; - - // We are potentially finished with the current batch of interactions. - // So we should clear them out of the pending interaction map. - // We do this at the start of commit in case cascading work is scheduled by commit phase lifecycles. - // In that event, interaction data may be added back into the pending map for a future commit. - // We also store the interactions we are about to commit so that we can notify subscribers after we're done. - // These are stored as an Array rather than a Set, - // Because the same interaction may be pending for multiple expiration times, - // In which case it's important that we decrement the count the right number of times after finishing. - root.pendingInteractionMap.forEach(function( - scheduledInteractions, - scheduledExpirationTime - ) { - if (scheduledExpirationTime <= committedExpirationTime) { - committedInteractions.push.apply( - committedInteractions, - Array.from(scheduledInteractions) - ); - root.pendingInteractionMap.delete(scheduledExpirationTime); - } - }); + prevInteractions = tracing.__interactionsRef.current; + tracing.__interactionsRef.current = root.memoizedInteractions; } // Reset this to null before calling lifecycles @@ -13454,13 +13714,13 @@ function commitRoot(root, finishedWork) { } onCommit(root, earliestRemainingTimeAfterCommit); - if (enableSchedulerTracking) { - tracking.__interactionsRef.current = prevInteractions; + if (enableSchedulerTracing) { + tracing.__interactionsRef.current = prevInteractions; var subscriber = void 0; try { - subscriber = tracking.__subscriberRef.current; + subscriber = tracing.__subscriberRef.current; if (subscriber !== null && root.memoizedInteractions.size > 0) { var threadID = computeThreadID( committedExpirationTime, @@ -13476,28 +13736,41 @@ function commitRoot(root, finishedWork) { unhandledError = error; } } finally { - // Don't update interaction counts if we're frozen due to suspense. - // In this case, we can skip the completed-work check entirely. - if (!suspenseDidTimeout) { - // Now that we're done, check the completed batch of interactions. - // If no more work is outstanding for a given interaction, - // We need to notify the subscribers that it's finished. - committedInteractions.forEach(function(interaction) { - interaction.__count--; - if (subscriber !== null && interaction.__count === 0) { - try { - subscriber.onInteractionScheduledWorkCompleted(interaction); - } catch (error) { - // It's not safe for commitRoot() to throw. - // Store the error for now and we'll re-throw in finishRendering(). - if (!hasUnhandledError) { - hasUnhandledError = true; - unhandledError = error; + // Clear completed interactions from the pending Map. + // Unless the render was suspended or cascading work was scheduled, + // In which case– leave pending interactions until the subsequent render. + var pendingInteractionMap = root.pendingInteractionMap; + pendingInteractionMap.forEach(function( + scheduledInteractions, + scheduledExpirationTime + ) { + // Only decrement the pending interaction count if we're done. + // If there's still work at the current priority, + // That indicates that we are waiting for suspense data. + if ( + earliestRemainingTimeAfterCommit === NoWork || + scheduledExpirationTime < earliestRemainingTimeAfterCommit + ) { + pendingInteractionMap.delete(scheduledExpirationTime); + + scheduledInteractions.forEach(function(interaction) { + interaction.__count--; + + if (subscriber !== null && interaction.__count === 0) { + try { + subscriber.onInteractionScheduledWorkCompleted(interaction); + } catch (error) { + // It's not safe for commitRoot() to throw. + // Store the error for now and we'll re-throw in finishRendering(). + if (!hasUnhandledError) { + hasUnhandledError = true; + unhandledError = error; + } } } - } - }); - } + }); + } + }); } } } @@ -13622,23 +13895,12 @@ function completeUnitOfWork(workInProgress) { nextRenderExpirationTime ); } - var next = nextUnitOfWork; stopWorkTimer(workInProgress); resetChildExpirationTime(workInProgress, nextRenderExpirationTime); { resetCurrentFiber(); } - if (next !== null) { - stopWorkTimer(workInProgress); - if (true && ReactFiberInstrumentation_1.debugTool) { - ReactFiberInstrumentation_1.debugTool.onCompleteWork(workInProgress); - } - // If completing this work spawned new work, do that next. We'll come - // back here again. - return next; - } - if ( returnFiber !== null && // Do not append effects to parents if a sibling failed to complete @@ -13700,7 +13962,7 @@ function completeUnitOfWork(workInProgress) { // This fiber did not complete because something threw. Pop values off // the stack without entering the complete phase. If this is a boundary, // capture values if possible. - var _next = unwindWork(workInProgress, nextRenderExpirationTime); + var next = unwindWork(workInProgress, nextRenderExpirationTime); // Because this fiber did not complete, don't reset its expiration time. if (workInProgress.effectTag & DidCapture) { // Restarting an error boundary @@ -13713,7 +13975,7 @@ function completeUnitOfWork(workInProgress) { resetCurrentFiber(); } - if (_next !== null) { + if (next !== null) { stopWorkTimer(workInProgress); if (true && ReactFiberInstrumentation_1.debugTool) { ReactFiberInstrumentation_1.debugTool.onCompleteWork(workInProgress); @@ -13721,14 +13983,14 @@ function completeUnitOfWork(workInProgress) { if (enableProfilerTimer) { // Include the time spent working on failed children before continuing. - if (_next.mode & ProfileMode) { - var actualDuration = _next.actualDuration; - var child = _next.child; + if (next.mode & ProfileMode) { + var actualDuration = next.actualDuration; + var child = next.child; while (child !== null) { actualDuration += child.actualDuration; child = child.sibling; } - _next.actualDuration = actualDuration; + next.actualDuration = actualDuration; } } @@ -13736,8 +13998,8 @@ function completeUnitOfWork(workInProgress) { // back here again. // Since we're restarting, remove anything that is not a host effect // from the effect tag. - _next.effectTag &= HostEffectMask; - return _next; + next.effectTag &= HostEffectMask; + return next; } if (returnFiber !== null) { @@ -13854,14 +14116,6 @@ function renderRoot(root, isYieldy, isExpired) { var expirationTime = root.nextExpirationTimeToWorkOn; - var prevInteractions = null; - if (enableSchedulerTracking) { - // We're about to start new tracked work. - // Restore pending interactions so cascading work triggered during the render phase will be accounted for. - prevInteractions = tracking.__interactionsRef.current; - tracking.__interactionsRef.current = root.memoizedInteractions; - } - // Check if we're starting from a fresh stack, or if we're resuming from // previously yielded work. if ( @@ -13880,7 +14134,7 @@ function renderRoot(root, isYieldy, isExpired) { ); root.pendingCommitExpirationTime = NoWork; - if (enableSchedulerTracking) { + if (enableSchedulerTracing) { // Determine which interactions this batch of work currently includes, // So that we can accurately attribute time spent working on it, var interactions = new Set(); @@ -13902,7 +14156,7 @@ function renderRoot(root, isYieldy, isExpired) { root.memoizedInteractions = interactions; if (interactions.size > 0) { - var subscriber = tracking.__subscriberRef.current; + var subscriber = tracing.__subscriberRef.current; if (subscriber !== null) { var threadID = computeThreadID( expirationTime, @@ -13911,7 +14165,7 @@ function renderRoot(root, isYieldy, isExpired) { try { subscriber.onWorkStarted(interactions, threadID); } catch (error) { - // Work thrown by an interaction tracking subscriber should be rethrown, + // Work thrown by an interaction tracing subscriber should be rethrown, // But only once it's safe (to avoid leaveing the scheduler in an invalid state). // Store the error for now and we'll re-throw in finishRendering(). if (!hasUnhandledError) { @@ -13924,6 +14178,14 @@ function renderRoot(root, isYieldy, isExpired) { } } + var prevInteractions = null; + if (enableSchedulerTracing) { + // We're about to start new traced work. + // Restore pending interactions so cascading work triggered during the render phase will be accounted for. + prevInteractions = tracing.__interactionsRef.current; + tracing.__interactionsRef.current = root.memoizedInteractions; + } + var didFatal = false; startWorkLoopTimer(nextUnitOfWork); @@ -13985,9 +14247,9 @@ function renderRoot(root, isYieldy, isExpired) { break; } while (true); - if (enableSchedulerTracking) { - // Tracked work is done for now; restore the previous interactions. - tracking.__interactionsRef.current = prevInteractions; + if (enableSchedulerTracing) { + // Traced work is done for now; restore the previous interactions. + tracing.__interactionsRef.current = prevInteractions; } // We're done performing work. Time to clean up. @@ -14137,7 +14399,7 @@ function dispatch(sourceFiber, value, expirationTime) { var ctor = fiber.type; var instance = fiber.stateNode; if ( - typeof ctor.getDerivedStateFromCatch === "function" || + typeof ctor.getDerivedStateFromError === "function" || (typeof instance.componentDidCatch === "function" && !isAlreadyFailedLegacyErrorBoundary(instance)) ) { @@ -14201,7 +14463,7 @@ function computeExpirationForFiber(currentTime, fiber) { } else { // No explicit expiration context was set, and we're not currently // performing work. Calculate a new expiration time. - if (fiber.mode & AsyncMode) { + if (fiber.mode & ConcurrentMode) { if (isBatchingInteractiveUpdates) { // This is an interactive update expirationTime = computeInteractiveExpiration(currentTime); @@ -14223,10 +14485,7 @@ function computeExpirationForFiber(currentTime, fiber) { // This is an interactive update. Keep track of the lowest pending // interactive expiration time. This allows us to synchronously flush // all interactive updates when needed. - if ( - lowestPriorityPendingInteractiveExpirationTime === NoWork || - expirationTime > lowestPriorityPendingInteractiveExpirationTime - ) { + if (expirationTime > lowestPriorityPendingInteractiveExpirationTime) { lowestPriorityPendingInteractiveExpirationTime = expirationTime; } } @@ -14254,6 +14513,7 @@ function retrySuspendedRoot(root, fiber, suspendedTime) { if (isPriorityLevelSuspended(root, suspendedTime)) { // Ping at the original level retryTime = suspendedTime; + markPingedPriorityLevel(root, retryTime); } else { // Placeholder already timed out. Compute a new expiration time @@ -14262,26 +14522,39 @@ function retrySuspendedRoot(root, fiber, suspendedTime) { markPendingPriorityLevel(root, retryTime); } + // TODO: If the placeholder fiber has already rendered the primary children + // without suspending (that is, all of the promises have already resolved), + // we should not trigger another update here. One case this happens is when + // we are in sync mode and a single promise is thrown both on initial render + // and on update; we attach two .then(retrySuspendedRoot) callbacks and each + // one performs Sync work, rerendering the Placeholder. + + if ((fiber.mode & ConcurrentMode) !== NoContext) { + if (root === nextRoot && nextRenderExpirationTime === suspendedTime) { + // Received a ping at the same priority level at which we're currently + // rendering. Restart from the root. + nextRoot = null; + } + } + scheduleWorkToRoot(fiber, retryTime); var rootExpirationTime = root.expirationTime; if (rootExpirationTime !== NoWork) { - if (enableSchedulerTracking) { - // Restore previous interactions so that new work is associated with them. - var prevInteractions = tracking.__interactionsRef.current; - tracking.__interactionsRef.current = root.memoizedInteractions; - // Because suspense timeouts do not decrement the interaction count, - // Continued suspense work should also not increment the count. - storeInteractionsForExpirationTime(root, rootExpirationTime, false); - requestWork(root, rootExpirationTime); - tracking.__interactionsRef.current = prevInteractions; - } else { - requestWork(root, rootExpirationTime); - } + requestWork(root, rootExpirationTime); } } } function scheduleWorkToRoot(fiber, expirationTime) { + recordScheduleUpdate(); + + { + if (fiber.tag === ClassComponent || fiber.tag === ClassComponentLazy) { + var instance = fiber.stateNode; + warnAboutInvalidUpdates(instance); + } + } + // Update the source fiber's expiration time if ( fiber.expirationTime === NoWork || @@ -14299,103 +14572,92 @@ function scheduleWorkToRoot(fiber, expirationTime) { } // Walk the parent path to the root and update the child expiration time. var node = fiber.return; + var root = null; if (node === null && fiber.tag === HostRoot) { - return fiber.stateNode; - } - while (node !== null) { - alternate = node.alternate; - if ( - node.childExpirationTime === NoWork || - node.childExpirationTime > expirationTime - ) { - node.childExpirationTime = expirationTime; + root = fiber.stateNode; + } else { + while (node !== null) { + alternate = node.alternate; if ( + node.childExpirationTime === NoWork || + node.childExpirationTime > expirationTime + ) { + node.childExpirationTime = expirationTime; + if ( + alternate !== null && + (alternate.childExpirationTime === NoWork || + alternate.childExpirationTime > expirationTime) + ) { + alternate.childExpirationTime = expirationTime; + } + } else if ( alternate !== null && (alternate.childExpirationTime === NoWork || alternate.childExpirationTime > expirationTime) ) { alternate.childExpirationTime = expirationTime; } - } else if ( - alternate !== null && - (alternate.childExpirationTime === NoWork || - alternate.childExpirationTime > expirationTime) - ) { - alternate.childExpirationTime = expirationTime; - } - if (node.return === null && node.tag === HostRoot) { - return node.stateNode; + if (node.return === null && node.tag === HostRoot) { + root = node.stateNode; + break; + } + node = node.return; } - node = node.return; } - return null; -} -function storeInteractionsForExpirationTime( - root, - expirationTime, - updateInteractionCounts -) { - if (!enableSchedulerTracking) { - return; + if (root === null) { + if ( + true && + (fiber.tag === ClassComponent || fiber.tag === ClassComponentLazy) + ) { + warnAboutUpdateOnUnmounted(fiber); + } + return null; } - var interactions = tracking.__interactionsRef.current; - if (interactions.size > 0) { - var pendingInteractions = root.pendingInteractionMap.get(expirationTime); - if (pendingInteractions != null) { - interactions.forEach(function(interaction) { - if (updateInteractionCounts && !pendingInteractions.has(interaction)) { - // Update the pending async work count for previously unscheduled interaction. - interaction.__count++; - } + if (enableSchedulerTracing) { + var interactions = tracing.__interactionsRef.current; + if (interactions.size > 0) { + var pendingInteractionMap = root.pendingInteractionMap; + var pendingInteractions = pendingInteractionMap.get(expirationTime); + if (pendingInteractions != null) { + interactions.forEach(function(interaction) { + if (!pendingInteractions.has(interaction)) { + // Update the pending async work count for previously unscheduled interaction. + interaction.__count++; + } - pendingInteractions.add(interaction); - }); - } else { - root.pendingInteractionMap.set(expirationTime, new Set(interactions)); + pendingInteractions.add(interaction); + }); + } else { + pendingInteractionMap.set(expirationTime, new Set(interactions)); - // Update the pending async work count for the current interactions. - if (updateInteractionCounts) { + // Update the pending async work count for the current interactions. interactions.forEach(function(interaction) { interaction.__count++; }); } - } - var subscriber = tracking.__subscriberRef.current; - if (subscriber !== null) { - var threadID = computeThreadID(expirationTime, root.interactionThreadID); - subscriber.onWorkScheduled(interactions, threadID); + var subscriber = tracing.__subscriberRef.current; + if (subscriber !== null) { + var threadID = computeThreadID( + expirationTime, + root.interactionThreadID + ); + subscriber.onWorkScheduled(interactions, threadID); + } } } + + return root; } function scheduleWork(fiber, expirationTime) { - recordScheduleUpdate(); - - { - if (fiber.tag === ClassComponent || fiber.tag === ClassComponentLazy) { - var instance = fiber.stateNode; - warnAboutInvalidUpdates(instance); - } - } - var root = scheduleWorkToRoot(fiber, expirationTime); if (root === null) { - if ( - true && - (fiber.tag === ClassComponent || fiber.tag === ClassComponentLazy) - ) { - warnAboutUpdateOnUnmounted(fiber); - } return; } - if (enableSchedulerTracking) { - storeInteractionsForExpirationTime(root, expirationTime, true); - } - if ( !isWorking && nextRenderExpirationTime !== NoWork && @@ -14543,16 +14805,7 @@ function onTimeout(root, finishedWork, suspendedExpirationTime) { // because we're at the top of a timer event. recomputeCurrentRendererTime(); currentSchedulerTime = currentRendererTime; - - if (enableSchedulerTracking) { - // Don't update pending interaction counts for suspense timeouts, - // Because we know we still need to do more work in this case. - suspenseDidTimeout = true; - flushRoot(root, suspendedExpirationTime); - suspenseDidTimeout = false; - } else { - flushRoot(root, suspendedExpirationTime); - } + flushRoot(root, suspendedExpirationTime); } } @@ -15189,8 +15442,8 @@ function findHostInstance$1(component) { return hostFiber.stateNode; } -function createContainer(containerInfo, isAsync, hydrate) { - return createFiberRoot(containerInfo, isAsync, hydrate); +function createContainer(containerInfo, isConcurrent, hydrate) { + return createFiberRoot(containerInfo, isConcurrent, hydrate); } function updateContainer(element, container, parentComponent, callback) { @@ -15266,7 +15519,7 @@ function createPortal( // TODO: this is special because it gets imported during build. -var ReactVersion = "16.5.0"; +var ReactVersion = "16.5.2"; // Modules provided by RN: var NativeMethodsMixin = function(findNodeHandle, findHostInstance) { diff --git a/Libraries/Renderer/oss/ReactFabric-prod.js b/Libraries/Renderer/oss/ReactFabric-prod.js index fb635b0d5a390b..3cee2cbcae1788 100644 --- a/Libraries/Renderer/oss/ReactFabric-prod.js +++ b/Libraries/Renderer/oss/ReactFabric-prod.js @@ -1029,9 +1029,12 @@ var ReactSharedInternals = REACT_PROFILER_TYPE = hasSymbol ? Symbol.for("react.profiler") : 60114, REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for("react.provider") : 60109, REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for("react.context") : 60110, - REACT_ASYNC_MODE_TYPE = hasSymbol ? Symbol.for("react.async_mode") : 60111, + REACT_CONCURRENT_MODE_TYPE = hasSymbol + ? Symbol.for("react.concurrent_mode") + : 60111, REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for("react.forward_ref") : 60112, REACT_PLACEHOLDER_TYPE = hasSymbol ? Symbol.for("react.placeholder") : 60113, + REACT_PURE_TYPE = hasSymbol ? Symbol.for("react.pure") : 60115, MAYBE_ITERATOR_SYMBOL = "function" === typeof Symbol && Symbol.iterator; function getIteratorFn(maybeIterable) { if (null === maybeIterable || "object" !== typeof maybeIterable) return null; @@ -1045,8 +1048,8 @@ function getComponentName(type) { if ("function" === typeof type) return type.displayName || type.name || null; if ("string" === typeof type) return type; switch (type) { - case REACT_ASYNC_MODE_TYPE: - return "AsyncMode"; + case REACT_CONCURRENT_MODE_TYPE: + return "ConcurrentMode"; case REACT_FRAGMENT_TYPE: return "Fragment"; case REACT_PORTAL_TYPE: @@ -1065,10 +1068,11 @@ function getComponentName(type) { case REACT_PROVIDER_TYPE: return "Context.Provider"; case REACT_FORWARD_REF_TYPE: + var renderFn = type.render; + renderFn = renderFn.displayName || renderFn.name || ""; return ( - (type = type.render), - (type = type.displayName || type.name || ""), - "" !== type ? "ForwardRef(" + type + ")" : "ForwardRef" + type.displayName || + ("" !== renderFn ? "ForwardRef(" + renderFn + ")" : "ForwardRef") ); } if ( @@ -1765,7 +1769,17 @@ function shouldConstruct(Component) { Component = Component.prototype; return !(!Component || !Component.isReactComponent); } -function createWorkInProgress(current, pendingProps, expirationTime) { +function resolveLazyComponentTag(fiber, Component) { + if ("function" === typeof Component) + return shouldConstruct(Component) ? 3 : 1; + if (void 0 !== Component && null !== Component) { + fiber = Component.$$typeof; + if (fiber === REACT_FORWARD_REF_TYPE) return 14; + if (fiber === REACT_PURE_TYPE) return 18; + } + return 4; +} +function createWorkInProgress(current, pendingProps) { var workInProgress = current.alternate; null === workInProgress ? ((workInProgress = new FiberNode( @@ -1784,10 +1798,7 @@ function createWorkInProgress(current, pendingProps, expirationTime) { (workInProgress.firstEffect = null), (workInProgress.lastEffect = null)); workInProgress.childExpirationTime = current.childExpirationTime; - workInProgress.expirationTime = - pendingProps !== current.pendingProps - ? expirationTime - : current.expirationTime; + workInProgress.expirationTime = current.expirationTime; workInProgress.child = current.child; workInProgress.memoizedProps = current.memoizedProps; workInProgress.memoizedState = current.memoizedState; @@ -1814,7 +1825,7 @@ function createFiberFromElement(element, mode, expirationTime) { expirationTime, key ); - case REACT_ASYNC_MODE_TYPE: + case REACT_CONCURRENT_MODE_TYPE: fiberTag = 10; mode |= 3; break; @@ -1844,6 +1855,9 @@ function createFiberFromElement(element, mode, expirationTime) { case REACT_FORWARD_REF_TYPE: fiberTag = 13; break a; + case REACT_PURE_TYPE: + fiberTag = 17; + break a; default: if ("function" === typeof type.then) { fiberTag = 4; @@ -2329,15 +2343,11 @@ function checkShouldComponentUpdate( newProps, oldState, newState, - nextLegacyContext + nextContext ) { workInProgress = workInProgress.stateNode; return "function" === typeof workInProgress.shouldComponentUpdate - ? workInProgress.shouldComponentUpdate( - newProps, - newState, - nextLegacyContext - ) + ? workInProgress.shouldComponentUpdate(newProps, newState, nextContext) : ctor.prototype && ctor.prototype.isPureReactComponent ? !shallowEqual(oldProps, newProps) || !shallowEqual(oldState, newState) : !0; @@ -2346,13 +2356,13 @@ function callComponentWillReceiveProps( workInProgress, instance, newProps, - nextLegacyContext + nextContext ) { workInProgress = instance.state; "function" === typeof instance.componentWillReceiveProps && - instance.componentWillReceiveProps(newProps, nextLegacyContext); + instance.componentWillReceiveProps(newProps, nextContext); "function" === typeof instance.UNSAFE_componentWillReceiveProps && - instance.UNSAFE_componentWillReceiveProps(newProps, nextLegacyContext); + instance.UNSAFE_componentWillReceiveProps(newProps, nextContext); instance.state !== workInProgress && classComponentUpdater.enqueueReplaceState(instance, instance.state, null); } @@ -2362,32 +2372,30 @@ function mountClassInstance( newProps, renderExpirationTime ) { - var instance = workInProgress.stateNode, - unmaskedContext = isContextProvider(ctor) - ? previousContext - : contextStackCursor.current; + var instance = workInProgress.stateNode; instance.props = newProps; instance.state = workInProgress.memoizedState; instance.refs = emptyRefsObject; - instance.context = getMaskedContext(workInProgress, unmaskedContext); - unmaskedContext = workInProgress.updateQueue; - null !== unmaskedContext && + var contextType = ctor.contextType; + "object" === typeof contextType && null !== contextType + ? (instance.context = contextType.unstable_read()) + : ((contextType = isContextProvider(ctor) + ? previousContext + : contextStackCursor.current), + (instance.context = getMaskedContext(workInProgress, contextType))); + contextType = workInProgress.updateQueue; + null !== contextType && (processUpdateQueue( workInProgress, - unmaskedContext, + contextType, newProps, instance, renderExpirationTime ), (instance.state = workInProgress.memoizedState)); - unmaskedContext = ctor.getDerivedStateFromProps; - "function" === typeof unmaskedContext && - (applyDerivedStateFromProps( - workInProgress, - ctor, - unmaskedContext, - newProps - ), + contextType = ctor.getDerivedStateFromProps; + "function" === typeof contextType && + (applyDerivedStateFromProps(workInProgress, ctor, contextType, newProps), (instance.state = workInProgress.memoizedState)); "function" === typeof ctor.getDerivedStateFromProps || "function" === typeof instance.getSnapshotBeforeUpdate || @@ -2400,11 +2408,11 @@ function mountClassInstance( instance.UNSAFE_componentWillMount(), ctor !== instance.state && classComponentUpdater.enqueueReplaceState(instance, instance.state, null), - (unmaskedContext = workInProgress.updateQueue), - null !== unmaskedContext && + (contextType = workInProgress.updateQueue), + null !== contextType && (processUpdateQueue( workInProgress, - unmaskedContext, + contextType, newProps, instance, renderExpirationTime @@ -2413,7 +2421,7 @@ function mountClassInstance( "function" === typeof instance.componentDidMount && (workInProgress.effectTag |= 4); } -var isArray$1 = Array.isArray; +var isArray = Array.isArray; function coerceRef(returnFiber, current$$1, element) { returnFiber = element.ref; if ( @@ -2427,7 +2435,7 @@ function coerceRef(returnFiber, current$$1, element) { element && (invariant( 2 === element.tag || 3 === element.tag, - "Stateless function components cannot have refs." + "Function components cannot have refs." ), (inst = element.stateNode)); invariant( @@ -2457,7 +2465,7 @@ function coerceRef(returnFiber, current$$1, element) { ); invariant( element._owner, - "Element ref was specified as a string (%s) but no owner was set. This could happen for one of the following reasons:\n1. You may be adding a ref to a functional component\n2. You may be adding a ref to a component that was not created inside a component's render method\n3. You have multiple copies of React loaded\nSee https://fb.me/react-refs-must-have-owner for more information.", + "Element ref was specified as a string (%s) but no owner was set. This could happen for one of the following reasons:\n1. You may be adding a ref to a function component\n2. You may be adding a ref to a component that was not created inside a component's render method\n3. You have multiple copies of React loaded\nSee https://fb.me/react-refs-must-have-owner for more information.", returnFiber ); } @@ -2641,7 +2649,7 @@ function ChildReconciler(shouldTrackSideEffects) { newChild ); } - if (isArray$1(newChild) || getIteratorFn(newChild)) + if (isArray(newChild) || getIteratorFn(newChild)) return ( (newChild = createFiberFromFragment( newChild, @@ -2681,7 +2689,7 @@ function ChildReconciler(shouldTrackSideEffects) { ? updatePortal(returnFiber, oldFiber, newChild, expirationTime) : null; } - if (isArray$1(newChild) || getIteratorFn(newChild)) + if (isArray(newChild) || getIteratorFn(newChild)) return null !== key ? null : updateFragment( @@ -2749,7 +2757,7 @@ function ChildReconciler(shouldTrackSideEffects) { ) ); } - if (isArray$1(newChild) || getIteratorFn(newChild)) + if (isArray(newChild) || getIteratorFn(newChild)) return ( (existingChildren = existingChildren.get(newIdx) || null), updateFragment( @@ -3088,7 +3096,7 @@ function ChildReconciler(shouldTrackSideEffects) { (returnFiber = currentFirstChild)), placeSingleChild(returnFiber) ); - if (isArray$1(newChild)) + if (isArray(newChild)) return reconcileChildrenArray( returnFiber, currentFirstChild, @@ -3249,6 +3257,36 @@ function updateForwardRef( workInProgress.memoizedProps = nextProps; return workInProgress.child; } +function updatePureComponent( + current$$1, + workInProgress, + Component, + nextProps, + updateExpirationTime, + renderExpirationTime +) { + var render = Component.render; + if ( + null !== current$$1 && + (0 === updateExpirationTime || + updateExpirationTime > renderExpirationTime) && + ((updateExpirationTime = current$$1.memoizedProps), + (Component = Component.compare), + (Component = null !== Component ? Component : shallowEqual), + Component(updateExpirationTime, nextProps)) + ) + return bailoutOnAlreadyFinishedWork( + current$$1, + workInProgress, + renderExpirationTime + ); + prepareToReadContext(workInProgress, renderExpirationTime); + render = render(nextProps); + workInProgress.effectTag |= 1; + reconcileChildren(current$$1, workInProgress, render, renderExpirationTime); + workInProgress.memoizedProps = nextProps; + return workInProgress.child; +} function markRef(current$$1, workInProgress) { var ref = workInProgress.ref; if ( @@ -3257,7 +3295,7 @@ function markRef(current$$1, workInProgress) { ) workInProgress.effectTag |= 128; } -function updateFunctionalComponent( +function updateFunctionComponent( current$$1, workInProgress, Component, @@ -3294,15 +3332,21 @@ function updateClassComponent( prepareToReadContext(workInProgress, renderExpirationTime); if (null === current$$1) if (null === workInProgress.stateNode) { - var unmaskedContext = isContextProvider(Component) - ? previousContext - : contextStackCursor.current, - contextTypes = Component.contextTypes, - isContextConsumer = null !== contextTypes && void 0 !== contextTypes; - contextTypes = isContextConsumer - ? getMaskedContext(workInProgress, unmaskedContext) - : emptyContextObject; - var instance = new Component(nextProps, contextTypes); + var isLegacyContextConsumer = !1, + unmaskedContext = emptyContextObject; + var context = Component.contextType; + "object" === typeof context && null !== context + ? (context = context.unstable_read()) + : ((unmaskedContext = isContextProvider(Component) + ? previousContext + : contextStackCursor.current), + (isLegacyContextConsumer = Component.contextTypes), + (context = (isLegacyContextConsumer = + null !== isLegacyContextConsumer && + void 0 !== isLegacyContextConsumer) + ? getMaskedContext(workInProgress, unmaskedContext) + : emptyContextObject)); + var instance = new Component(nextProps, context); workInProgress.memoizedState = null !== instance.state && void 0 !== instance.state ? instance.state @@ -3310,10 +3354,10 @@ function updateClassComponent( instance.updater = classComponentUpdater; workInProgress.stateNode = instance; instance._reactInternalFiber = workInProgress; - isContextConsumer && - ((isContextConsumer = workInProgress.stateNode), - (isContextConsumer.__reactInternalMemoizedUnmaskedChildContext = unmaskedContext), - (isContextConsumer.__reactInternalMemoizedMaskedChildContext = contextTypes)); + isLegacyContextConsumer && + ((isLegacyContextConsumer = workInProgress.stateNode), + (isLegacyContextConsumer.__reactInternalMemoizedUnmaskedChildContext = unmaskedContext), + (isLegacyContextConsumer.__reactInternalMemoizedMaskedChildContext = context)); mountClassInstance( workInProgress, Component, @@ -3323,13 +3367,16 @@ function updateClassComponent( nextProps = !0; } else { unmaskedContext = workInProgress.stateNode; - contextTypes = workInProgress.memoizedProps; - unmaskedContext.props = contextTypes; + isLegacyContextConsumer = workInProgress.memoizedProps; + unmaskedContext.props = isLegacyContextConsumer; var oldContext = unmaskedContext.context; - isContextConsumer = isContextProvider(Component) - ? previousContext - : contextStackCursor.current; - isContextConsumer = getMaskedContext(workInProgress, isContextConsumer); + context = Component.contextType; + "object" === typeof context && null !== context + ? (context = context.unstable_read()) + : ((context = isContextProvider(Component) + ? previousContext + : contextStackCursor.current), + (context = getMaskedContext(workInProgress, context))); var getDerivedStateFromProps = Component.getDerivedStateFromProps; (instance = "function" === typeof getDerivedStateFromProps || @@ -3337,12 +3384,12 @@ function updateClassComponent( ("function" !== typeof unmaskedContext.UNSAFE_componentWillReceiveProps && "function" !== typeof unmaskedContext.componentWillReceiveProps) || - ((contextTypes !== nextProps || oldContext !== isContextConsumer) && + ((isLegacyContextConsumer !== nextProps || oldContext !== context) && callComponentWillReceiveProps( workInProgress, unmaskedContext, nextProps, - isContextConsumer + context )); hasForceUpdate = !1; var oldState = workInProgress.memoizedState; @@ -3357,7 +3404,7 @@ function updateClassComponent( renderExpirationTime ), (oldContext = workInProgress.memoizedState)); - contextTypes !== nextProps || + isLegacyContextConsumer !== nextProps || oldState !== oldContext || didPerformWorkStackCursor.current || hasForceUpdate @@ -3369,16 +3416,16 @@ function updateClassComponent( nextProps ), (oldContext = workInProgress.memoizedState)), - (contextTypes = + (isLegacyContextConsumer = hasForceUpdate || checkShouldComponentUpdate( workInProgress, Component, - contextTypes, + isLegacyContextConsumer, nextProps, oldState, oldContext, - isContextConsumer + context )) ? (instance || ("function" !== @@ -3397,21 +3444,24 @@ function updateClassComponent( (workInProgress.memoizedState = oldContext)), (unmaskedContext.props = nextProps), (unmaskedContext.state = oldContext), - (unmaskedContext.context = isContextConsumer), - (nextProps = contextTypes)) + (unmaskedContext.context = context), + (nextProps = isLegacyContextConsumer)) : ("function" === typeof unmaskedContext.componentDidMount && (workInProgress.effectTag |= 4), (nextProps = !1)); } else (unmaskedContext = workInProgress.stateNode), - (contextTypes = workInProgress.memoizedProps), - (unmaskedContext.props = contextTypes), + (isLegacyContextConsumer = workInProgress.memoizedProps), + (unmaskedContext.props = isLegacyContextConsumer), (oldContext = unmaskedContext.context), - (isContextConsumer = isContextProvider(Component) - ? previousContext - : contextStackCursor.current), - (isContextConsumer = getMaskedContext(workInProgress, isContextConsumer)), + (context = Component.contextType), + "object" === typeof context && null !== context + ? (context = context.unstable_read()) + : ((context = isContextProvider(Component) + ? previousContext + : contextStackCursor.current), + (context = getMaskedContext(workInProgress, context))), (getDerivedStateFromProps = Component.getDerivedStateFromProps), (instance = "function" === typeof getDerivedStateFromProps || @@ -3419,12 +3469,12 @@ function updateClassComponent( ("function" !== typeof unmaskedContext.UNSAFE_componentWillReceiveProps && "function" !== typeof unmaskedContext.componentWillReceiveProps) || - ((contextTypes !== nextProps || oldContext !== isContextConsumer) && + ((isLegacyContextConsumer !== nextProps || oldContext !== context) && callComponentWillReceiveProps( workInProgress, unmaskedContext, nextProps, - isContextConsumer + context )), (hasForceUpdate = !1), (oldContext = workInProgress.memoizedState), @@ -3439,7 +3489,7 @@ function updateClassComponent( renderExpirationTime ), (oldState = workInProgress.memoizedState)), - contextTypes !== nextProps || + isLegacyContextConsumer !== nextProps || oldContext !== oldState || didPerformWorkStackCursor.current || hasForceUpdate @@ -3456,11 +3506,11 @@ function updateClassComponent( checkShouldComponentUpdate( workInProgress, Component, - contextTypes, + isLegacyContextConsumer, nextProps, oldContext, oldState, - isContextConsumer + context )) ? (instance || ("function" !== @@ -3470,39 +3520,39 @@ function updateClassComponent( unmaskedContext.componentWillUpdate( nextProps, oldState, - isContextConsumer + context ), "function" === typeof unmaskedContext.UNSAFE_componentWillUpdate && unmaskedContext.UNSAFE_componentWillUpdate( nextProps, oldState, - isContextConsumer + context )), "function" === typeof unmaskedContext.componentDidUpdate && (workInProgress.effectTag |= 4), "function" === typeof unmaskedContext.getSnapshotBeforeUpdate && (workInProgress.effectTag |= 256)) : ("function" !== typeof unmaskedContext.componentDidUpdate || - (contextTypes === current$$1.memoizedProps && + (isLegacyContextConsumer === current$$1.memoizedProps && oldContext === current$$1.memoizedState) || (workInProgress.effectTag |= 4), "function" !== typeof unmaskedContext.getSnapshotBeforeUpdate || - (contextTypes === current$$1.memoizedProps && + (isLegacyContextConsumer === current$$1.memoizedProps && oldContext === current$$1.memoizedState) || (workInProgress.effectTag |= 256), (workInProgress.memoizedProps = nextProps), (workInProgress.memoizedState = oldState)), (unmaskedContext.props = nextProps), (unmaskedContext.state = oldState), - (unmaskedContext.context = isContextConsumer), + (unmaskedContext.context = context), (nextProps = getDerivedStateFromProps)) : ("function" !== typeof unmaskedContext.componentDidUpdate || - (contextTypes === current$$1.memoizedProps && + (isLegacyContextConsumer === current$$1.memoizedProps && oldContext === current$$1.memoizedState) || (workInProgress.effectTag |= 4), "function" !== typeof unmaskedContext.getSnapshotBeforeUpdate || - (contextTypes === current$$1.memoizedProps && + (isLegacyContextConsumer === current$$1.memoizedProps && oldContext === current$$1.memoizedState) || (workInProgress.effectTag |= 256), (nextProps = !1)); @@ -3536,18 +3586,30 @@ function finishClassComponent( ); shouldUpdate = workInProgress.stateNode; ReactCurrentOwner$3.current = workInProgress; - var nextChildren = didCaptureError ? null : shouldUpdate.render(); + var nextChildren = + didCaptureError && "function" !== typeof Component.getDerivedStateFromError + ? null + : shouldUpdate.render(); workInProgress.effectTag |= 1; - null !== current$$1 && - didCaptureError && - (reconcileChildren(current$$1, workInProgress, null, renderExpirationTime), - (workInProgress.child = null)); - reconcileChildren( - current$$1, - workInProgress, - nextChildren, - renderExpirationTime - ); + null !== current$$1 && didCaptureError + ? ((workInProgress.child = reconcileChildFibers( + workInProgress, + current$$1.child, + null, + renderExpirationTime + )), + (workInProgress.child = reconcileChildFibers( + workInProgress, + null, + nextChildren, + renderExpirationTime + ))) + : reconcileChildren( + current$$1, + workInProgress, + nextChildren, + renderExpirationTime + ); workInProgress.memoizedState = shouldUpdate.state; workInProgress.memoizedProps = shouldUpdate.props; hasContext && invalidateContextProvider(workInProgress, Component, !0); @@ -3575,122 +3637,6 @@ function resolveDefaultProps(Component, baseProps) { } return baseProps; } -function mountIndeterminateComponent( - current$$1, - workInProgress, - Component, - renderExpirationTime -) { - invariant( - null === current$$1, - "An indeterminate component should never have mounted. This error is likely caused by a bug in React. Please file an issue." - ); - var props = workInProgress.pendingProps; - if ( - "object" === typeof Component && - null !== Component && - "function" === typeof Component.then - ) { - Component = readLazyComponentType(Component); - var JSCompiler_inline_result = Component; - JSCompiler_inline_result = - "function" === typeof JSCompiler_inline_result - ? shouldConstruct(JSCompiler_inline_result) - ? 3 - : 1 - : void 0 !== JSCompiler_inline_result && - null !== JSCompiler_inline_result && - JSCompiler_inline_result.$$typeof - ? 14 - : 4; - JSCompiler_inline_result = workInProgress.tag = JSCompiler_inline_result; - var resolvedProps = resolveDefaultProps(Component, props); - switch (JSCompiler_inline_result) { - case 1: - return updateFunctionalComponent( - current$$1, - workInProgress, - Component, - resolvedProps, - renderExpirationTime - ); - case 3: - return updateClassComponent( - current$$1, - workInProgress, - Component, - resolvedProps, - renderExpirationTime - ); - case 14: - return updateForwardRef( - current$$1, - workInProgress, - Component, - resolvedProps, - renderExpirationTime - ); - default: - invariant( - !1, - "Element type is invalid. Received a promise that resolves to: %s. Promise elements must resolve to a class or function.", - Component - ); - } - } - JSCompiler_inline_result = getMaskedContext( - workInProgress, - contextStackCursor.current - ); - prepareToReadContext(workInProgress, renderExpirationTime); - JSCompiler_inline_result = Component(props, JSCompiler_inline_result); - workInProgress.effectTag |= 1; - if ( - "object" === typeof JSCompiler_inline_result && - null !== JSCompiler_inline_result && - "function" === typeof JSCompiler_inline_result.render && - void 0 === JSCompiler_inline_result.$$typeof - ) { - workInProgress.tag = 2; - isContextProvider(Component) - ? ((resolvedProps = !0), pushContextProvider(workInProgress)) - : (resolvedProps = !1); - workInProgress.memoizedState = - null !== JSCompiler_inline_result.state && - void 0 !== JSCompiler_inline_result.state - ? JSCompiler_inline_result.state - : null; - var getDerivedStateFromProps = Component.getDerivedStateFromProps; - "function" === typeof getDerivedStateFromProps && - applyDerivedStateFromProps( - workInProgress, - Component, - getDerivedStateFromProps, - props - ); - JSCompiler_inline_result.updater = classComponentUpdater; - workInProgress.stateNode = JSCompiler_inline_result; - JSCompiler_inline_result._reactInternalFiber = workInProgress; - mountClassInstance(workInProgress, Component, props, renderExpirationTime); - return finishClassComponent( - current$$1, - workInProgress, - Component, - !0, - resolvedProps, - renderExpirationTime - ); - } - workInProgress.tag = 0; - reconcileChildren( - current$$1, - workInProgress, - JSCompiler_inline_result, - renderExpirationTime - ); - workInProgress.memoizedProps = props; - return workInProgress.child; -} function bailoutOnAlreadyFinishedWork( current$$1, workInProgress, @@ -3732,6 +3678,8 @@ function bailoutOnAlreadyFinishedWork( function beginWork(current$$1, workInProgress, renderExpirationTime) { var updateExpirationTime = workInProgress.expirationTime; if ( + null !== current$$1 && + current$$1.memoizedProps === workInProgress.pendingProps && !didPerformWorkStackCursor.current && (0 === updateExpirationTime || updateExpirationTime > renderExpirationTime) ) { @@ -3768,14 +3716,129 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { workInProgress.expirationTime = 0; switch (workInProgress.tag) { case 4: - return mountIndeterminateComponent( - current$$1, - workInProgress, - workInProgress.type, - renderExpirationTime + var Component = workInProgress.type; + invariant( + null === current$$1, + "An indeterminate component should never have mounted. This error is likely caused by a bug in React. Please file an issue." ); + var props = workInProgress.pendingProps; + if ( + "object" === typeof Component && + null !== Component && + "function" === typeof Component.then + ) { + Component = readLazyComponentType(Component); + var resolvedTag = (workInProgress.tag = resolveLazyComponentTag( + workInProgress, + Component + )), + resolvedProps = resolveDefaultProps(Component, props), + child = void 0; + switch (resolvedTag) { + case 1: + child = updateFunctionComponent( + current$$1, + workInProgress, + Component, + resolvedProps, + renderExpirationTime + ); + break; + case 3: + child = updateClassComponent( + current$$1, + workInProgress, + Component, + resolvedProps, + renderExpirationTime + ); + break; + case 14: + child = updateForwardRef( + current$$1, + workInProgress, + Component, + resolvedProps, + renderExpirationTime + ); + break; + case 18: + child = updatePureComponent( + current$$1, + workInProgress, + Component, + resolvedProps, + updateExpirationTime, + renderExpirationTime + ); + break; + default: + invariant( + !1, + "Element type is invalid. Received a promise that resolves to: %s. Promise elements must resolve to a class or function.", + Component + ); + } + workInProgress.memoizedProps = props; + workInProgress = child; + } else + (updateExpirationTime = getMaskedContext( + workInProgress, + contextStackCursor.current + )), + prepareToReadContext(workInProgress, renderExpirationTime), + (updateExpirationTime = Component(props, updateExpirationTime)), + (workInProgress.effectTag |= 1), + "object" === typeof updateExpirationTime && + null !== updateExpirationTime && + "function" === typeof updateExpirationTime.render && + void 0 === updateExpirationTime.$$typeof + ? ((workInProgress.tag = 2), + isContextProvider(Component) + ? ((resolvedTag = !0), pushContextProvider(workInProgress)) + : (resolvedTag = !1), + (workInProgress.memoizedState = + null !== updateExpirationTime.state && + void 0 !== updateExpirationTime.state + ? updateExpirationTime.state + : null), + (resolvedProps = Component.getDerivedStateFromProps), + "function" === typeof resolvedProps && + applyDerivedStateFromProps( + workInProgress, + Component, + resolvedProps, + props + ), + (updateExpirationTime.updater = classComponentUpdater), + (workInProgress.stateNode = updateExpirationTime), + (updateExpirationTime._reactInternalFiber = workInProgress), + mountClassInstance( + workInProgress, + Component, + props, + renderExpirationTime + ), + (workInProgress = finishClassComponent( + current$$1, + workInProgress, + Component, + !0, + resolvedTag, + renderExpirationTime + ))) + : ((workInProgress.tag = 0), + reconcileChildren( + current$$1, + workInProgress, + updateExpirationTime, + renderExpirationTime + ), + (workInProgress.memoizedProps = props), + (workInProgress = workInProgress.child)); + return workInProgress; case 0: - return updateFunctionalComponent( + return updateFunctionComponent( current$$1, workInProgress, workInProgress.type, @@ -3783,17 +3846,19 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { renderExpirationTime ); case 1: - var _Component5 = workInProgress.type._reactResult; - updateExpirationTime = workInProgress.pendingProps; - current$$1 = updateFunctionalComponent( - current$$1, - workInProgress, - _Component5, - resolveDefaultProps(_Component5, updateExpirationTime), - renderExpirationTime + return ( + (props = workInProgress.type._reactResult), + (Component = workInProgress.pendingProps), + (current$$1 = updateFunctionComponent( + current$$1, + workInProgress, + props, + resolveDefaultProps(props, Component), + renderExpirationTime + )), + (workInProgress.memoizedProps = Component), + current$$1 ); - workInProgress.memoizedProps = updateExpirationTime; - return current$$1; case 2: return updateClassComponent( current$$1, @@ -3804,37 +3869,37 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { ); case 3: return ( - (_Component5 = workInProgress.type._reactResult), - (updateExpirationTime = workInProgress.pendingProps), + (props = workInProgress.type._reactResult), + (Component = workInProgress.pendingProps), (current$$1 = updateClassComponent( current$$1, workInProgress, - _Component5, - resolveDefaultProps(_Component5, updateExpirationTime), + props, + resolveDefaultProps(props, Component), renderExpirationTime )), - (workInProgress.memoizedProps = updateExpirationTime), + (workInProgress.memoizedProps = Component), current$$1 ); case 5: return ( pushHostRootContext(workInProgress), - (updateExpirationTime = workInProgress.updateQueue), + (Component = workInProgress.updateQueue), invariant( - null !== updateExpirationTime, + null !== Component, "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." ), - (_Component5 = workInProgress.memoizedState), - (_Component5 = null !== _Component5 ? _Component5.element : null), + (props = workInProgress.memoizedState), + (props = null !== props ? props.element : null), processUpdateQueue( workInProgress, - updateExpirationTime, + Component, workInProgress.pendingProps, null, renderExpirationTime ), - (updateExpirationTime = workInProgress.memoizedState.element), - updateExpirationTime === _Component5 + (Component = workInProgress.memoizedState.element), + Component === props ? (workInProgress = bailoutOnAlreadyFinishedWork( current$$1, workInProgress, @@ -3843,7 +3908,7 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { : (reconcileChildren( current$$1, workInProgress, - updateExpirationTime, + Component, renderExpirationTime ), (workInProgress = workInProgress.child)), @@ -3853,16 +3918,16 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { return ( pushHostContext(workInProgress), null === current$$1 && tryToClaimNextHydratableInstance(workInProgress), - (updateExpirationTime = workInProgress.pendingProps), - (_Component5 = updateExpirationTime.children), + (Component = workInProgress.pendingProps), + (props = Component.children), markRef(current$$1, workInProgress), reconcileChildren( current$$1, workInProgress, - _Component5, + props, renderExpirationTime ), - (workInProgress.memoizedProps = updateExpirationTime), + (workInProgress.memoizedProps = Component), (workInProgress = workInProgress.child), workInProgress ); @@ -3880,21 +3945,21 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { workInProgress, workInProgress.stateNode.containerInfo ), - (updateExpirationTime = workInProgress.pendingProps), + (Component = workInProgress.pendingProps), null === current$$1 ? (workInProgress.child = reconcileChildFibers( workInProgress, null, - updateExpirationTime, + Component, renderExpirationTime )) : reconcileChildren( current$$1, workInProgress, - updateExpirationTime, + Component, renderExpirationTime ), - (workInProgress.memoizedProps = updateExpirationTime), + (workInProgress.memoizedProps = Component), workInProgress.child ); case 13: @@ -3907,79 +3972,82 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { ); case 14: return ( - (_Component5 = workInProgress.type._reactResult), - (updateExpirationTime = workInProgress.pendingProps), + (props = workInProgress.type._reactResult), + (Component = workInProgress.pendingProps), (current$$1 = updateForwardRef( current$$1, workInProgress, - _Component5, - resolveDefaultProps(_Component5, updateExpirationTime), + props, + resolveDefaultProps(props, Component), renderExpirationTime )), - (workInProgress.memoizedProps = updateExpirationTime), + (workInProgress.memoizedProps = Component), current$$1 ); case 9: return ( - (updateExpirationTime = workInProgress.pendingProps), + (Component = workInProgress.pendingProps), reconcileChildren( current$$1, workInProgress, - updateExpirationTime, + Component, renderExpirationTime ), - (workInProgress.memoizedProps = updateExpirationTime), + (workInProgress.memoizedProps = Component), workInProgress.child ); case 10: return ( - (updateExpirationTime = workInProgress.pendingProps.children), + (Component = workInProgress.pendingProps.children), reconcileChildren( current$$1, workInProgress, - updateExpirationTime, + Component, renderExpirationTime ), - (workInProgress.memoizedProps = updateExpirationTime), + (workInProgress.memoizedProps = Component), workInProgress.child ); case 15: return ( - (updateExpirationTime = workInProgress.pendingProps), + (Component = workInProgress.pendingProps), reconcileChildren( current$$1, workInProgress, - updateExpirationTime.children, + Component.children, renderExpirationTime ), - (workInProgress.memoizedProps = updateExpirationTime), + (workInProgress.memoizedProps = Component), workInProgress.child ); case 12: a: { - updateExpirationTime = workInProgress.type._context; - _Component5 = workInProgress.pendingProps; - var oldProps = workInProgress.memoizedProps, - newValue = _Component5.value; - workInProgress.memoizedProps = _Component5; - pushProvider(workInProgress, newValue); - if (null !== oldProps) { - var oldValue = oldProps.value; - newValue = - (oldValue === newValue && - (0 !== oldValue || 1 / oldValue === 1 / newValue)) || - (oldValue !== oldValue && newValue !== newValue) - ? 0 - : ("function" === - typeof updateExpirationTime._calculateChangedBits - ? updateExpirationTime._calculateChangedBits( - oldValue, - newValue - ) - : 1073741823) | 0; - if (0 === newValue) { + Component = workInProgress.type._context; + props = workInProgress.pendingProps; + resolvedTag = workInProgress.memoizedProps; + updateExpirationTime = props.value; + workInProgress.memoizedProps = props; + pushProvider(workInProgress, updateExpirationTime); + if (null !== resolvedTag) + if ( + ((resolvedProps = resolvedTag.value), + (updateExpirationTime = + (resolvedProps === updateExpirationTime && + (0 !== resolvedProps || + 1 / resolvedProps === 1 / updateExpirationTime)) || + (resolvedProps !== resolvedProps && + updateExpirationTime !== updateExpirationTime) + ? 0 + : ("function" === typeof Component._calculateChangedBits + ? Component._calculateChangedBits( + resolvedProps, + updateExpirationTime + ) + : 1073741823) | 0), + 0 === updateExpirationTime) + ) { if ( - oldProps.children === _Component5.children && + resolvedTag.children === props.children && !didPerformWorkStackCursor.current ) { workInProgress = bailoutOnAlreadyFinishedWork( @@ -3991,87 +4059,85 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { } } else for ( - oldProps = workInProgress.child, - null !== oldProps && (oldProps.return = workInProgress); - null !== oldProps; + resolvedTag = workInProgress.child, + null !== resolvedTag && (resolvedTag.return = workInProgress); + null !== resolvedTag; ) { - oldValue = oldProps.firstContextDependency; - if (null !== oldValue) { + resolvedProps = resolvedTag.firstContextDependency; + if (null !== resolvedProps) { do { if ( - oldValue.context === updateExpirationTime && - 0 !== (oldValue.observedBits & newValue) + resolvedProps.context === Component && + 0 !== (resolvedProps.observedBits & updateExpirationTime) ) { - if (2 === oldProps.tag || 3 === oldProps.tag) { - var nextFiber = createUpdate(renderExpirationTime); - nextFiber.tag = 2; - enqueueUpdate(oldProps, nextFiber); - } + if (2 === resolvedTag.tag || 3 === resolvedTag.tag) + (child = createUpdate(renderExpirationTime)), + (child.tag = 2), + enqueueUpdate(resolvedTag, child); if ( - 0 === oldProps.expirationTime || - oldProps.expirationTime > renderExpirationTime + 0 === resolvedTag.expirationTime || + resolvedTag.expirationTime > renderExpirationTime ) - oldProps.expirationTime = renderExpirationTime; - nextFiber = oldProps.alternate; - null !== nextFiber && - (0 === nextFiber.expirationTime || - nextFiber.expirationTime > renderExpirationTime) && - (nextFiber.expirationTime = renderExpirationTime); - for (var node = oldProps.return; null !== node; ) { - nextFiber = node.alternate; + resolvedTag.expirationTime = renderExpirationTime; + child = resolvedTag.alternate; + null !== child && + (0 === child.expirationTime || + child.expirationTime > renderExpirationTime) && + (child.expirationTime = renderExpirationTime); + for (var node = resolvedTag.return; null !== node; ) { + child = node.alternate; if ( 0 === node.childExpirationTime || node.childExpirationTime > renderExpirationTime ) (node.childExpirationTime = renderExpirationTime), - null !== nextFiber && - (0 === nextFiber.childExpirationTime || - nextFiber.childExpirationTime > + null !== child && + (0 === child.childExpirationTime || + child.childExpirationTime > renderExpirationTime) && - (nextFiber.childExpirationTime = renderExpirationTime); + (child.childExpirationTime = renderExpirationTime); else if ( - null !== nextFiber && - (0 === nextFiber.childExpirationTime || - nextFiber.childExpirationTime > renderExpirationTime) + null !== child && + (0 === child.childExpirationTime || + child.childExpirationTime > renderExpirationTime) ) - nextFiber.childExpirationTime = renderExpirationTime; + child.childExpirationTime = renderExpirationTime; else break; node = node.return; } } - nextFiber = oldProps.child; - oldValue = oldValue.next; - } while (null !== oldValue); + child = resolvedTag.child; + resolvedProps = resolvedProps.next; + } while (null !== resolvedProps); } else - nextFiber = - 12 === oldProps.tag - ? oldProps.type === workInProgress.type + child = + 12 === resolvedTag.tag + ? resolvedTag.type === workInProgress.type ? null - : oldProps.child - : oldProps.child; - if (null !== nextFiber) nextFiber.return = oldProps; + : resolvedTag.child + : resolvedTag.child; + if (null !== child) child.return = resolvedTag; else - for (nextFiber = oldProps; null !== nextFiber; ) { - if (nextFiber === workInProgress) { - nextFiber = null; + for (child = resolvedTag; null !== child; ) { + if (child === workInProgress) { + child = null; break; } - oldProps = nextFiber.sibling; - if (null !== oldProps) { - oldProps.return = nextFiber.return; - nextFiber = oldProps; + resolvedTag = child.sibling; + if (null !== resolvedTag) { + resolvedTag.return = child.return; + child = resolvedTag; break; } - nextFiber = nextFiber.return; + child = child.return; } - oldProps = nextFiber; + resolvedTag = child; } - } reconcileChildren( current$$1, workInProgress, - _Component5.children, + props.children, renderExpirationTime ); workInProgress = workInProgress.child; @@ -4079,25 +4145,49 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { return workInProgress; case 11: return ( - (newValue = workInProgress.type), - (updateExpirationTime = workInProgress.pendingProps), - (_Component5 = updateExpirationTime.children), + (updateExpirationTime = workInProgress.type), + (Component = workInProgress.pendingProps), + (props = Component.children), prepareToReadContext(workInProgress, renderExpirationTime), - (newValue = readContext( - newValue, - updateExpirationTime.unstable_observedBits + (updateExpirationTime = readContext( + updateExpirationTime, + Component.unstable_observedBits )), - (_Component5 = _Component5(newValue)), + (props = props(updateExpirationTime)), (workInProgress.effectTag |= 1), reconcileChildren( current$$1, workInProgress, - _Component5, + props, renderExpirationTime ), - (workInProgress.memoizedProps = updateExpirationTime), + (workInProgress.memoizedProps = Component), workInProgress.child ); + case 17: + return updatePureComponent( + current$$1, + workInProgress, + workInProgress.type, + workInProgress.pendingProps, + updateExpirationTime, + renderExpirationTime + ); + case 18: + return ( + (props = workInProgress.type._reactResult), + (Component = workInProgress.pendingProps), + (current$$1 = updatePureComponent( + current$$1, + workInProgress, + props, + resolveDefaultProps(props, Component), + updateExpirationTime, + renderExpirationTime + )), + (workInProgress.memoizedProps = Component), + current$$1 + ); default: invariant( !1, @@ -4300,13 +4390,21 @@ function createRootErrorUpdate(fiber, errorInfo, expirationTime) { function createClassErrorUpdate(fiber, errorInfo, expirationTime) { expirationTime = createUpdate(expirationTime); expirationTime.tag = 3; + var getDerivedStateFromError = fiber.type.getDerivedStateFromError; + if ("function" === typeof getDerivedStateFromError) { + var error$jscomp$0 = errorInfo.value; + expirationTime.payload = function() { + return getDerivedStateFromError(error$jscomp$0); + }; + } var inst = fiber.stateNode; null !== inst && "function" === typeof inst.componentDidCatch && (expirationTime.callback = function() { - null === legacyErrorBoundariesThatAlreadyFailed - ? (legacyErrorBoundariesThatAlreadyFailed = new Set([this])) - : legacyErrorBoundariesThatAlreadyFailed.add(this); + "function" !== typeof getDerivedStateFromError && + (null === legacyErrorBoundariesThatAlreadyFailed + ? (legacyErrorBoundariesThatAlreadyFailed = new Set([this])) + : legacyErrorBoundariesThatAlreadyFailed.add(this)); var error = errorInfo.value, stack = errorInfo.stack; logError(fiber, errorInfo); @@ -4548,6 +4646,9 @@ function completeUnitOfWork(workInProgress) { break; case 11: break; + case 17: + case 18: + break; case 4: invariant( !1, @@ -4559,31 +4660,28 @@ function completeUnitOfWork(workInProgress) { "Unknown unit of work tag. This error is likely caused by a bug in React. Please file an issue." ); } - current$$1 = nextUnitOfWork = null; - instance = workInProgress; + nextUnitOfWork = null; + current$$1 = workInProgress; if ( 1073741823 === nextRenderExpirationTime || - 1073741823 !== instance.childExpirationTime + 1073741823 !== current$$1.childExpirationTime ) { - rootContainerInstance = 0; - for (current = instance.child; null !== current; ) { - viewConfig = current.expirationTime; - type = current.childExpirationTime; - if ( - 0 === rootContainerInstance || - (0 !== viewConfig && viewConfig < rootContainerInstance) - ) - rootContainerInstance = viewConfig; - if ( - 0 === rootContainerInstance || - (0 !== type && type < rootContainerInstance) - ) - rootContainerInstance = type; - current = current.sibling; + instance = 0; + for ( + rootContainerInstance = current$$1.child; + null !== rootContainerInstance; + + ) { + current = rootContainerInstance.expirationTime; + viewConfig = rootContainerInstance.childExpirationTime; + if (0 === instance || (0 !== current && current < instance)) + instance = current; + if (0 === instance || (0 !== viewConfig && viewConfig < instance)) + instance = viewConfig; + rootContainerInstance = rootContainerInstance.sibling; } - instance.childExpirationTime = rootContainerInstance; + current$$1.childExpirationTime = instance; } - if (null !== current$$1) return current$$1; null !== returnFiber && 0 === (returnFiber.effectTag & 512) && (null === returnFiber.firstEffect && @@ -4688,13 +4786,17 @@ function renderRoot(root, isYieldy, isExpired) { case 2: case 3: sourceFiber$jscomp$0 = value; - var instance = returnFiber$jscomp$0.stateNode; + var ctor = returnFiber$jscomp$0.type, + instance = returnFiber$jscomp$0.stateNode; if ( 0 === (returnFiber$jscomp$0.effectTag & 64) && - null !== instance && - "function" === typeof instance.componentDidCatch && - (null === legacyErrorBoundariesThatAlreadyFailed || - !legacyErrorBoundariesThatAlreadyFailed.has(instance)) + ("function" === typeof ctor.getDerivedStateFromError || + (null !== instance && + "function" === typeof instance.componentDidCatch && + (null === legacyErrorBoundariesThatAlreadyFailed || + !legacyErrorBoundariesThatAlreadyFailed.has( + instance + )))) ) { returnFiber$jscomp$0.effectTag |= 1024; returnFiber$jscomp$0.expirationTime = returnFiber; @@ -4791,7 +4893,7 @@ function captureCommitPhaseError(fiber, error) { var instance = JSCompiler_inline_result.stateNode; if ( "function" === - typeof JSCompiler_inline_result.type.getDerivedStateFromCatch || + typeof JSCompiler_inline_result.type.getDerivedStateFromError || ("function" === typeof instance.componentDidCatch && (null === legacyErrorBoundariesThatAlreadyFailed || !legacyErrorBoundariesThatAlreadyFailed.has(instance))) @@ -4839,43 +4941,40 @@ function computeExpirationForFiber(currentTime, fiber) { (currentTime += 1)) : (currentTime = 1); isBatchingInteractiveUpdates && - (0 === lowestPriorityPendingInteractiveExpirationTime || - currentTime > lowestPriorityPendingInteractiveExpirationTime) && + currentTime > lowestPriorityPendingInteractiveExpirationTime && (lowestPriorityPendingInteractiveExpirationTime = currentTime); return currentTime; } function scheduleWork(fiber, expirationTime) { - a: { - if (0 === fiber.expirationTime || fiber.expirationTime > expirationTime) - fiber.expirationTime = expirationTime; - var alternate = fiber.alternate; - null !== alternate && - (0 === alternate.expirationTime || - alternate.expirationTime > expirationTime) && - (alternate.expirationTime = expirationTime); - var node = fiber.return; - if (null === node && 5 === fiber.tag) fiber = fiber.stateNode; - else { - for (; null !== node; ) { - alternate = node.alternate; - if ( - 0 === node.childExpirationTime || - node.childExpirationTime > expirationTime - ) - node.childExpirationTime = expirationTime; - null !== alternate && - (0 === alternate.childExpirationTime || - alternate.childExpirationTime > expirationTime) && - (alternate.childExpirationTime = expirationTime); - if (null === node.return && 5 === node.tag) { - fiber = node.stateNode; - break a; - } - node = node.return; + if (0 === fiber.expirationTime || fiber.expirationTime > expirationTime) + fiber.expirationTime = expirationTime; + var alternate = fiber.alternate; + null !== alternate && + (0 === alternate.expirationTime || + alternate.expirationTime > expirationTime) && + (alternate.expirationTime = expirationTime); + var node = fiber.return, + root = null; + if (null === node && 5 === fiber.tag) root = fiber.stateNode; + else + for (; null !== node; ) { + alternate = node.alternate; + if ( + 0 === node.childExpirationTime || + node.childExpirationTime > expirationTime + ) + node.childExpirationTime = expirationTime; + null !== alternate && + (0 === alternate.childExpirationTime || + alternate.childExpirationTime > expirationTime) && + (alternate.childExpirationTime = expirationTime); + if (null === node.return && 5 === node.tag) { + root = node.stateNode; + break; } - fiber = null; + node = node.return; } - } + fiber = null === root ? null : root; if (null !== fiber) { !isWorking && 0 !== nextRenderExpirationTime && @@ -4883,29 +4982,28 @@ function scheduleWork(fiber, expirationTime) { resetStack(); markPendingPriorityLevel(fiber, expirationTime); if (!isWorking || isCommitting$1 || nextRoot !== fiber) { - expirationTime = fiber; - fiber = fiber.expirationTime; - if (null === expirationTime.nextScheduledRoot) - (expirationTime.expirationTime = fiber), + expirationTime = fiber.expirationTime; + if (null === fiber.nextScheduledRoot) + (fiber.expirationTime = expirationTime), null === lastScheduledRoot - ? ((firstScheduledRoot = lastScheduledRoot = expirationTime), - (expirationTime.nextScheduledRoot = expirationTime)) - : ((lastScheduledRoot = lastScheduledRoot.nextScheduledRoot = expirationTime), + ? ((firstScheduledRoot = lastScheduledRoot = fiber), + (fiber.nextScheduledRoot = fiber)) + : ((lastScheduledRoot = lastScheduledRoot.nextScheduledRoot = fiber), (lastScheduledRoot.nextScheduledRoot = firstScheduledRoot)); else if ( - ((alternate = expirationTime.expirationTime), - 0 === alternate || fiber < alternate) + ((alternate = fiber.expirationTime), + 0 === alternate || expirationTime < alternate) ) - expirationTime.expirationTime = fiber; + fiber.expirationTime = expirationTime; isRendering || (isBatchingUpdates ? isUnbatchingUpdates && - ((nextFlushedRoot = expirationTime), + ((nextFlushedRoot = fiber), (nextFlushedExpirationTime = 1), - performWorkOnRoot(expirationTime, 1, !0)) - : 1 === fiber + performWorkOnRoot(fiber, 1, !0)) + : 1 === expirationTime ? performWork(1, null) - : scheduleCallbackWithExpirationTime(expirationTime, fiber)); + : scheduleCallbackWithExpirationTime(fiber, expirationTime)); } nestedUpdateCount > NESTED_UPDATE_LIMIT && ((nestedUpdateCount = 0), @@ -5824,7 +5922,7 @@ var roots = new Map(), findFiberByHostInstance: getInstanceFromInstance, getInspectorDataForViewTag: getInspectorDataForViewTag, bundleType: 0, - version: "16.5.0", + version: "16.5.2", rendererPackageName: "react-native-renderer" }); var ReactFabric$2 = { default: ReactFabric }, diff --git a/Libraries/Renderer/oss/ReactFabric-profiling.js b/Libraries/Renderer/oss/ReactFabric-profiling.js index de00c9c48571bf..1723349f630569 100644 --- a/Libraries/Renderer/oss/ReactFabric-profiling.js +++ b/Libraries/Renderer/oss/ReactFabric-profiling.js @@ -19,7 +19,7 @@ var ReactNativeViewConfigRegistry = require("ReactNativeViewConfigRegistry"), flattenStyle = require("flattenStyle"), TextInputState = require("TextInputState"), FabricUIManager = require("FabricUIManager"), - tracking = require("schedule/tracking"), + tracing = require("scheduler/tracing"), ExceptionsManager = require("ExceptionsManager"); function invariant(condition, format, a, b, c, d, e, f) { if (!condition) { @@ -1030,9 +1030,12 @@ var ReactSharedInternals = REACT_PROFILER_TYPE = hasSymbol ? Symbol.for("react.profiler") : 60114, REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for("react.provider") : 60109, REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for("react.context") : 60110, - REACT_ASYNC_MODE_TYPE = hasSymbol ? Symbol.for("react.async_mode") : 60111, + REACT_CONCURRENT_MODE_TYPE = hasSymbol + ? Symbol.for("react.concurrent_mode") + : 60111, REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for("react.forward_ref") : 60112, REACT_PLACEHOLDER_TYPE = hasSymbol ? Symbol.for("react.placeholder") : 60113, + REACT_PURE_TYPE = hasSymbol ? Symbol.for("react.pure") : 60115, MAYBE_ITERATOR_SYMBOL = "function" === typeof Symbol && Symbol.iterator; function getIteratorFn(maybeIterable) { if (null === maybeIterable || "object" !== typeof maybeIterable) return null; @@ -1046,8 +1049,8 @@ function getComponentName(type) { if ("function" === typeof type) return type.displayName || type.name || null; if ("string" === typeof type) return type; switch (type) { - case REACT_ASYNC_MODE_TYPE: - return "AsyncMode"; + case REACT_CONCURRENT_MODE_TYPE: + return "ConcurrentMode"; case REACT_FRAGMENT_TYPE: return "Fragment"; case REACT_PORTAL_TYPE: @@ -1066,10 +1069,11 @@ function getComponentName(type) { case REACT_PROVIDER_TYPE: return "Context.Provider"; case REACT_FORWARD_REF_TYPE: + var renderFn = type.render; + renderFn = renderFn.displayName || renderFn.name || ""; return ( - (type = type.render), - (type = type.displayName || type.name || ""), - "" !== type ? "ForwardRef(" + type + ")" : "ForwardRef" + type.displayName || + ("" !== renderFn ? "ForwardRef(" + renderFn + ")" : "ForwardRef") ); } if ( @@ -1771,7 +1775,17 @@ function shouldConstruct(Component) { Component = Component.prototype; return !(!Component || !Component.isReactComponent); } -function createWorkInProgress(current, pendingProps, expirationTime) { +function resolveLazyComponentTag(fiber, Component) { + if ("function" === typeof Component) + return shouldConstruct(Component) ? 3 : 1; + if (void 0 !== Component && null !== Component) { + fiber = Component.$$typeof; + if (fiber === REACT_FORWARD_REF_TYPE) return 14; + if (fiber === REACT_PURE_TYPE) return 18; + } + return 4; +} +function createWorkInProgress(current, pendingProps) { var workInProgress = current.alternate; null === workInProgress ? ((workInProgress = new FiberNode( @@ -1792,10 +1806,7 @@ function createWorkInProgress(current, pendingProps, expirationTime) { (workInProgress.actualDuration = 0), (workInProgress.actualStartTime = -1)); workInProgress.childExpirationTime = current.childExpirationTime; - workInProgress.expirationTime = - pendingProps !== current.pendingProps - ? expirationTime - : current.expirationTime; + workInProgress.expirationTime = current.expirationTime; workInProgress.child = current.child; workInProgress.memoizedProps = current.memoizedProps; workInProgress.memoizedState = current.memoizedState; @@ -1824,7 +1835,7 @@ function createFiberFromElement(element, mode, expirationTime) { expirationTime, key ); - case REACT_ASYNC_MODE_TYPE: + case REACT_CONCURRENT_MODE_TYPE: fiberTag = 10; mode |= 3; break; @@ -1854,6 +1865,9 @@ function createFiberFromElement(element, mode, expirationTime) { case REACT_FORWARD_REF_TYPE: fiberTag = 13; break a; + case REACT_PURE_TYPE: + fiberTag = 17; + break a; default: if ("function" === typeof type.then) { fiberTag = 4; @@ -2413,15 +2427,11 @@ function checkShouldComponentUpdate( newProps, oldState, newState, - nextLegacyContext + nextContext ) { workInProgress = workInProgress.stateNode; return "function" === typeof workInProgress.shouldComponentUpdate - ? workInProgress.shouldComponentUpdate( - newProps, - newState, - nextLegacyContext - ) + ? workInProgress.shouldComponentUpdate(newProps, newState, nextContext) : ctor.prototype && ctor.prototype.isPureReactComponent ? !shallowEqual(oldProps, newProps) || !shallowEqual(oldState, newState) : !0; @@ -2430,13 +2440,13 @@ function callComponentWillReceiveProps( workInProgress, instance, newProps, - nextLegacyContext + nextContext ) { workInProgress = instance.state; "function" === typeof instance.componentWillReceiveProps && - instance.componentWillReceiveProps(newProps, nextLegacyContext); + instance.componentWillReceiveProps(newProps, nextContext); "function" === typeof instance.UNSAFE_componentWillReceiveProps && - instance.UNSAFE_componentWillReceiveProps(newProps, nextLegacyContext); + instance.UNSAFE_componentWillReceiveProps(newProps, nextContext); instance.state !== workInProgress && classComponentUpdater.enqueueReplaceState(instance, instance.state, null); } @@ -2446,32 +2456,30 @@ function mountClassInstance( newProps, renderExpirationTime ) { - var instance = workInProgress.stateNode, - unmaskedContext = isContextProvider(ctor) - ? previousContext - : contextStackCursor.current; + var instance = workInProgress.stateNode; instance.props = newProps; instance.state = workInProgress.memoizedState; instance.refs = emptyRefsObject; - instance.context = getMaskedContext(workInProgress, unmaskedContext); - unmaskedContext = workInProgress.updateQueue; - null !== unmaskedContext && + var contextType = ctor.contextType; + "object" === typeof contextType && null !== contextType + ? (instance.context = contextType.unstable_read()) + : ((contextType = isContextProvider(ctor) + ? previousContext + : contextStackCursor.current), + (instance.context = getMaskedContext(workInProgress, contextType))); + contextType = workInProgress.updateQueue; + null !== contextType && (processUpdateQueue( workInProgress, - unmaskedContext, + contextType, newProps, instance, renderExpirationTime ), (instance.state = workInProgress.memoizedState)); - unmaskedContext = ctor.getDerivedStateFromProps; - "function" === typeof unmaskedContext && - (applyDerivedStateFromProps( - workInProgress, - ctor, - unmaskedContext, - newProps - ), + contextType = ctor.getDerivedStateFromProps; + "function" === typeof contextType && + (applyDerivedStateFromProps(workInProgress, ctor, contextType, newProps), (instance.state = workInProgress.memoizedState)); "function" === typeof ctor.getDerivedStateFromProps || "function" === typeof instance.getSnapshotBeforeUpdate || @@ -2484,11 +2492,11 @@ function mountClassInstance( instance.UNSAFE_componentWillMount(), ctor !== instance.state && classComponentUpdater.enqueueReplaceState(instance, instance.state, null), - (unmaskedContext = workInProgress.updateQueue), - null !== unmaskedContext && + (contextType = workInProgress.updateQueue), + null !== contextType && (processUpdateQueue( workInProgress, - unmaskedContext, + contextType, newProps, instance, renderExpirationTime @@ -2497,7 +2505,7 @@ function mountClassInstance( "function" === typeof instance.componentDidMount && (workInProgress.effectTag |= 4); } -var isArray$1 = Array.isArray; +var isArray = Array.isArray; function coerceRef(returnFiber, current$$1, element) { returnFiber = element.ref; if ( @@ -2511,7 +2519,7 @@ function coerceRef(returnFiber, current$$1, element) { element && (invariant( 2 === element.tag || 3 === element.tag, - "Stateless function components cannot have refs." + "Function components cannot have refs." ), (inst = element.stateNode)); invariant( @@ -2541,7 +2549,7 @@ function coerceRef(returnFiber, current$$1, element) { ); invariant( element._owner, - "Element ref was specified as a string (%s) but no owner was set. This could happen for one of the following reasons:\n1. You may be adding a ref to a functional component\n2. You may be adding a ref to a component that was not created inside a component's render method\n3. You have multiple copies of React loaded\nSee https://fb.me/react-refs-must-have-owner for more information.", + "Element ref was specified as a string (%s) but no owner was set. This could happen for one of the following reasons:\n1. You may be adding a ref to a function component\n2. You may be adding a ref to a component that was not created inside a component's render method\n3. You have multiple copies of React loaded\nSee https://fb.me/react-refs-must-have-owner for more information.", returnFiber ); } @@ -2725,7 +2733,7 @@ function ChildReconciler(shouldTrackSideEffects) { newChild ); } - if (isArray$1(newChild) || getIteratorFn(newChild)) + if (isArray(newChild) || getIteratorFn(newChild)) return ( (newChild = createFiberFromFragment( newChild, @@ -2765,7 +2773,7 @@ function ChildReconciler(shouldTrackSideEffects) { ? updatePortal(returnFiber, oldFiber, newChild, expirationTime) : null; } - if (isArray$1(newChild) || getIteratorFn(newChild)) + if (isArray(newChild) || getIteratorFn(newChild)) return null !== key ? null : updateFragment( @@ -2833,7 +2841,7 @@ function ChildReconciler(shouldTrackSideEffects) { ) ); } - if (isArray$1(newChild) || getIteratorFn(newChild)) + if (isArray(newChild) || getIteratorFn(newChild)) return ( (existingChildren = existingChildren.get(newIdx) || null), updateFragment( @@ -3172,7 +3180,7 @@ function ChildReconciler(shouldTrackSideEffects) { (returnFiber = currentFirstChild)), placeSingleChild(returnFiber) ); - if (isArray$1(newChild)) + if (isArray(newChild)) return reconcileChildrenArray( returnFiber, currentFirstChild, @@ -3333,6 +3341,36 @@ function updateForwardRef( workInProgress.memoizedProps = nextProps; return workInProgress.child; } +function updatePureComponent( + current$$1, + workInProgress, + Component, + nextProps, + updateExpirationTime, + renderExpirationTime +) { + var render = Component.render; + if ( + null !== current$$1 && + (0 === updateExpirationTime || + updateExpirationTime > renderExpirationTime) && + ((updateExpirationTime = current$$1.memoizedProps), + (Component = Component.compare), + (Component = null !== Component ? Component : shallowEqual), + Component(updateExpirationTime, nextProps)) + ) + return bailoutOnAlreadyFinishedWork( + current$$1, + workInProgress, + renderExpirationTime + ); + prepareToReadContext(workInProgress, renderExpirationTime); + render = render(nextProps); + workInProgress.effectTag |= 1; + reconcileChildren(current$$1, workInProgress, render, renderExpirationTime); + workInProgress.memoizedProps = nextProps; + return workInProgress.child; +} function markRef(current$$1, workInProgress) { var ref = workInProgress.ref; if ( @@ -3341,7 +3379,7 @@ function markRef(current$$1, workInProgress) { ) workInProgress.effectTag |= 128; } -function updateFunctionalComponent( +function updateFunctionComponent( current$$1, workInProgress, Component, @@ -3378,15 +3416,21 @@ function updateClassComponent( prepareToReadContext(workInProgress, renderExpirationTime); if (null === current$$1) if (null === workInProgress.stateNode) { - var unmaskedContext = isContextProvider(Component) - ? previousContext - : contextStackCursor.current, - contextTypes = Component.contextTypes, - isContextConsumer = null !== contextTypes && void 0 !== contextTypes; - contextTypes = isContextConsumer - ? getMaskedContext(workInProgress, unmaskedContext) - : emptyContextObject; - var instance = new Component(nextProps, contextTypes); + var isLegacyContextConsumer = !1, + unmaskedContext = emptyContextObject; + var context = Component.contextType; + "object" === typeof context && null !== context + ? (context = context.unstable_read()) + : ((unmaskedContext = isContextProvider(Component) + ? previousContext + : contextStackCursor.current), + (isLegacyContextConsumer = Component.contextTypes), + (context = (isLegacyContextConsumer = + null !== isLegacyContextConsumer && + void 0 !== isLegacyContextConsumer) + ? getMaskedContext(workInProgress, unmaskedContext) + : emptyContextObject)); + var instance = new Component(nextProps, context); workInProgress.memoizedState = null !== instance.state && void 0 !== instance.state ? instance.state @@ -3394,10 +3438,10 @@ function updateClassComponent( instance.updater = classComponentUpdater; workInProgress.stateNode = instance; instance._reactInternalFiber = workInProgress; - isContextConsumer && - ((isContextConsumer = workInProgress.stateNode), - (isContextConsumer.__reactInternalMemoizedUnmaskedChildContext = unmaskedContext), - (isContextConsumer.__reactInternalMemoizedMaskedChildContext = contextTypes)); + isLegacyContextConsumer && + ((isLegacyContextConsumer = workInProgress.stateNode), + (isLegacyContextConsumer.__reactInternalMemoizedUnmaskedChildContext = unmaskedContext), + (isLegacyContextConsumer.__reactInternalMemoizedMaskedChildContext = context)); mountClassInstance( workInProgress, Component, @@ -3407,13 +3451,16 @@ function updateClassComponent( nextProps = !0; } else { unmaskedContext = workInProgress.stateNode; - contextTypes = workInProgress.memoizedProps; - unmaskedContext.props = contextTypes; + isLegacyContextConsumer = workInProgress.memoizedProps; + unmaskedContext.props = isLegacyContextConsumer; var oldContext = unmaskedContext.context; - isContextConsumer = isContextProvider(Component) - ? previousContext - : contextStackCursor.current; - isContextConsumer = getMaskedContext(workInProgress, isContextConsumer); + context = Component.contextType; + "object" === typeof context && null !== context + ? (context = context.unstable_read()) + : ((context = isContextProvider(Component) + ? previousContext + : contextStackCursor.current), + (context = getMaskedContext(workInProgress, context))); var getDerivedStateFromProps = Component.getDerivedStateFromProps; (instance = "function" === typeof getDerivedStateFromProps || @@ -3421,12 +3468,12 @@ function updateClassComponent( ("function" !== typeof unmaskedContext.UNSAFE_componentWillReceiveProps && "function" !== typeof unmaskedContext.componentWillReceiveProps) || - ((contextTypes !== nextProps || oldContext !== isContextConsumer) && + ((isLegacyContextConsumer !== nextProps || oldContext !== context) && callComponentWillReceiveProps( workInProgress, unmaskedContext, nextProps, - isContextConsumer + context )); hasForceUpdate = !1; var oldState = workInProgress.memoizedState; @@ -3441,7 +3488,7 @@ function updateClassComponent( renderExpirationTime ), (oldContext = workInProgress.memoizedState)); - contextTypes !== nextProps || + isLegacyContextConsumer !== nextProps || oldState !== oldContext || didPerformWorkStackCursor.current || hasForceUpdate @@ -3453,16 +3500,16 @@ function updateClassComponent( nextProps ), (oldContext = workInProgress.memoizedState)), - (contextTypes = + (isLegacyContextConsumer = hasForceUpdate || checkShouldComponentUpdate( workInProgress, Component, - contextTypes, + isLegacyContextConsumer, nextProps, oldState, oldContext, - isContextConsumer + context )) ? (instance || ("function" !== @@ -3481,21 +3528,24 @@ function updateClassComponent( (workInProgress.memoizedState = oldContext)), (unmaskedContext.props = nextProps), (unmaskedContext.state = oldContext), - (unmaskedContext.context = isContextConsumer), - (nextProps = contextTypes)) + (unmaskedContext.context = context), + (nextProps = isLegacyContextConsumer)) : ("function" === typeof unmaskedContext.componentDidMount && (workInProgress.effectTag |= 4), (nextProps = !1)); } else (unmaskedContext = workInProgress.stateNode), - (contextTypes = workInProgress.memoizedProps), - (unmaskedContext.props = contextTypes), + (isLegacyContextConsumer = workInProgress.memoizedProps), + (unmaskedContext.props = isLegacyContextConsumer), (oldContext = unmaskedContext.context), - (isContextConsumer = isContextProvider(Component) - ? previousContext - : contextStackCursor.current), - (isContextConsumer = getMaskedContext(workInProgress, isContextConsumer)), + (context = Component.contextType), + "object" === typeof context && null !== context + ? (context = context.unstable_read()) + : ((context = isContextProvider(Component) + ? previousContext + : contextStackCursor.current), + (context = getMaskedContext(workInProgress, context))), (getDerivedStateFromProps = Component.getDerivedStateFromProps), (instance = "function" === typeof getDerivedStateFromProps || @@ -3503,12 +3553,12 @@ function updateClassComponent( ("function" !== typeof unmaskedContext.UNSAFE_componentWillReceiveProps && "function" !== typeof unmaskedContext.componentWillReceiveProps) || - ((contextTypes !== nextProps || oldContext !== isContextConsumer) && + ((isLegacyContextConsumer !== nextProps || oldContext !== context) && callComponentWillReceiveProps( workInProgress, unmaskedContext, nextProps, - isContextConsumer + context )), (hasForceUpdate = !1), (oldContext = workInProgress.memoizedState), @@ -3523,7 +3573,7 @@ function updateClassComponent( renderExpirationTime ), (oldState = workInProgress.memoizedState)), - contextTypes !== nextProps || + isLegacyContextConsumer !== nextProps || oldContext !== oldState || didPerformWorkStackCursor.current || hasForceUpdate @@ -3540,11 +3590,11 @@ function updateClassComponent( checkShouldComponentUpdate( workInProgress, Component, - contextTypes, + isLegacyContextConsumer, nextProps, oldContext, oldState, - isContextConsumer + context )) ? (instance || ("function" !== @@ -3554,39 +3604,39 @@ function updateClassComponent( unmaskedContext.componentWillUpdate( nextProps, oldState, - isContextConsumer + context ), "function" === typeof unmaskedContext.UNSAFE_componentWillUpdate && unmaskedContext.UNSAFE_componentWillUpdate( nextProps, oldState, - isContextConsumer + context )), "function" === typeof unmaskedContext.componentDidUpdate && (workInProgress.effectTag |= 4), "function" === typeof unmaskedContext.getSnapshotBeforeUpdate && (workInProgress.effectTag |= 256)) : ("function" !== typeof unmaskedContext.componentDidUpdate || - (contextTypes === current$$1.memoizedProps && + (isLegacyContextConsumer === current$$1.memoizedProps && oldContext === current$$1.memoizedState) || (workInProgress.effectTag |= 4), "function" !== typeof unmaskedContext.getSnapshotBeforeUpdate || - (contextTypes === current$$1.memoizedProps && + (isLegacyContextConsumer === current$$1.memoizedProps && oldContext === current$$1.memoizedState) || (workInProgress.effectTag |= 256), (workInProgress.memoizedProps = nextProps), (workInProgress.memoizedState = oldState)), (unmaskedContext.props = nextProps), (unmaskedContext.state = oldState), - (unmaskedContext.context = isContextConsumer), + (unmaskedContext.context = context), (nextProps = getDerivedStateFromProps)) : ("function" !== typeof unmaskedContext.componentDidUpdate || - (contextTypes === current$$1.memoizedProps && + (isLegacyContextConsumer === current$$1.memoizedProps && oldContext === current$$1.memoizedState) || (workInProgress.effectTag |= 4), "function" !== typeof unmaskedContext.getSnapshotBeforeUpdate || - (contextTypes === current$$1.memoizedProps && + (isLegacyContextConsumer === current$$1.memoizedProps && oldContext === current$$1.memoizedState) || (workInProgress.effectTag |= 256), (nextProps = !1)); @@ -3620,21 +3670,34 @@ function finishClassComponent( ); shouldUpdate = workInProgress.stateNode; ReactCurrentOwner$3.current = workInProgress; - if (didCaptureError) { + if ( + didCaptureError && + "function" !== typeof Component.getDerivedStateFromError + ) { var nextChildren = null; profilerStartTime = -1; } else nextChildren = shouldUpdate.render(); workInProgress.effectTag |= 1; - null !== current$$1 && - didCaptureError && - (reconcileChildren(current$$1, workInProgress, null, renderExpirationTime), - (workInProgress.child = null)); - reconcileChildren( - current$$1, - workInProgress, - nextChildren, - renderExpirationTime - ); + null !== current$$1 && didCaptureError + ? ((didCaptureError = nextChildren), + (workInProgress.child = reconcileChildFibers( + workInProgress, + current$$1.child, + null, + renderExpirationTime + )), + (workInProgress.child = reconcileChildFibers( + workInProgress, + null, + didCaptureError, + renderExpirationTime + ))) + : reconcileChildren( + current$$1, + workInProgress, + nextChildren, + renderExpirationTime + ); workInProgress.memoizedState = shouldUpdate.state; workInProgress.memoizedProps = shouldUpdate.props; hasContext && invalidateContextProvider(workInProgress, Component, !0); @@ -3662,122 +3725,6 @@ function resolveDefaultProps(Component, baseProps) { } return baseProps; } -function mountIndeterminateComponent( - current$$1, - workInProgress, - Component, - renderExpirationTime -) { - invariant( - null === current$$1, - "An indeterminate component should never have mounted. This error is likely caused by a bug in React. Please file an issue." - ); - var props = workInProgress.pendingProps; - if ( - "object" === typeof Component && - null !== Component && - "function" === typeof Component.then - ) { - Component = readLazyComponentType(Component); - var JSCompiler_inline_result = Component; - JSCompiler_inline_result = - "function" === typeof JSCompiler_inline_result - ? shouldConstruct(JSCompiler_inline_result) - ? 3 - : 1 - : void 0 !== JSCompiler_inline_result && - null !== JSCompiler_inline_result && - JSCompiler_inline_result.$$typeof - ? 14 - : 4; - JSCompiler_inline_result = workInProgress.tag = JSCompiler_inline_result; - var resolvedProps = resolveDefaultProps(Component, props); - switch (JSCompiler_inline_result) { - case 1: - return updateFunctionalComponent( - current$$1, - workInProgress, - Component, - resolvedProps, - renderExpirationTime - ); - case 3: - return updateClassComponent( - current$$1, - workInProgress, - Component, - resolvedProps, - renderExpirationTime - ); - case 14: - return updateForwardRef( - current$$1, - workInProgress, - Component, - resolvedProps, - renderExpirationTime - ); - default: - invariant( - !1, - "Element type is invalid. Received a promise that resolves to: %s. Promise elements must resolve to a class or function.", - Component - ); - } - } - JSCompiler_inline_result = getMaskedContext( - workInProgress, - contextStackCursor.current - ); - prepareToReadContext(workInProgress, renderExpirationTime); - JSCompiler_inline_result = Component(props, JSCompiler_inline_result); - workInProgress.effectTag |= 1; - if ( - "object" === typeof JSCompiler_inline_result && - null !== JSCompiler_inline_result && - "function" === typeof JSCompiler_inline_result.render && - void 0 === JSCompiler_inline_result.$$typeof - ) { - workInProgress.tag = 2; - isContextProvider(Component) - ? ((resolvedProps = !0), pushContextProvider(workInProgress)) - : (resolvedProps = !1); - workInProgress.memoizedState = - null !== JSCompiler_inline_result.state && - void 0 !== JSCompiler_inline_result.state - ? JSCompiler_inline_result.state - : null; - var getDerivedStateFromProps = Component.getDerivedStateFromProps; - "function" === typeof getDerivedStateFromProps && - applyDerivedStateFromProps( - workInProgress, - Component, - getDerivedStateFromProps, - props - ); - JSCompiler_inline_result.updater = classComponentUpdater; - workInProgress.stateNode = JSCompiler_inline_result; - JSCompiler_inline_result._reactInternalFiber = workInProgress; - mountClassInstance(workInProgress, Component, props, renderExpirationTime); - return finishClassComponent( - current$$1, - workInProgress, - Component, - !0, - resolvedProps, - renderExpirationTime - ); - } - workInProgress.tag = 0; - reconcileChildren( - current$$1, - workInProgress, - JSCompiler_inline_result, - renderExpirationTime - ); - workInProgress.memoizedProps = props; - return workInProgress.child; -} function bailoutOnAlreadyFinishedWork( current$$1, workInProgress, @@ -3820,6 +3767,8 @@ function bailoutOnAlreadyFinishedWork( function beginWork(current$$1, workInProgress, renderExpirationTime) { var updateExpirationTime = workInProgress.expirationTime; if ( + null !== current$$1 && + current$$1.memoizedProps === workInProgress.pendingProps && !didPerformWorkStackCursor.current && (0 === updateExpirationTime || updateExpirationTime > renderExpirationTime) ) { @@ -3859,14 +3808,129 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { workInProgress.expirationTime = 0; switch (workInProgress.tag) { case 4: - return mountIndeterminateComponent( - current$$1, - workInProgress, - workInProgress.type, - renderExpirationTime + var Component = workInProgress.type; + invariant( + null === current$$1, + "An indeterminate component should never have mounted. This error is likely caused by a bug in React. Please file an issue." ); + var props = workInProgress.pendingProps; + if ( + "object" === typeof Component && + null !== Component && + "function" === typeof Component.then + ) { + Component = readLazyComponentType(Component); + var resolvedTag = (workInProgress.tag = resolveLazyComponentTag( + workInProgress, + Component + )), + resolvedProps = resolveDefaultProps(Component, props), + child = void 0; + switch (resolvedTag) { + case 1: + child = updateFunctionComponent( + current$$1, + workInProgress, + Component, + resolvedProps, + renderExpirationTime + ); + break; + case 3: + child = updateClassComponent( + current$$1, + workInProgress, + Component, + resolvedProps, + renderExpirationTime + ); + break; + case 14: + child = updateForwardRef( + current$$1, + workInProgress, + Component, + resolvedProps, + renderExpirationTime + ); + break; + case 18: + child = updatePureComponent( + current$$1, + workInProgress, + Component, + resolvedProps, + updateExpirationTime, + renderExpirationTime + ); + break; + default: + invariant( + !1, + "Element type is invalid. Received a promise that resolves to: %s. Promise elements must resolve to a class or function.", + Component + ); + } + workInProgress.memoizedProps = props; + workInProgress = child; + } else + (updateExpirationTime = getMaskedContext( + workInProgress, + contextStackCursor.current + )), + prepareToReadContext(workInProgress, renderExpirationTime), + (updateExpirationTime = Component(props, updateExpirationTime)), + (workInProgress.effectTag |= 1), + "object" === typeof updateExpirationTime && + null !== updateExpirationTime && + "function" === typeof updateExpirationTime.render && + void 0 === updateExpirationTime.$$typeof + ? ((workInProgress.tag = 2), + isContextProvider(Component) + ? ((resolvedTag = !0), pushContextProvider(workInProgress)) + : (resolvedTag = !1), + (workInProgress.memoizedState = + null !== updateExpirationTime.state && + void 0 !== updateExpirationTime.state + ? updateExpirationTime.state + : null), + (resolvedProps = Component.getDerivedStateFromProps), + "function" === typeof resolvedProps && + applyDerivedStateFromProps( + workInProgress, + Component, + resolvedProps, + props + ), + (updateExpirationTime.updater = classComponentUpdater), + (workInProgress.stateNode = updateExpirationTime), + (updateExpirationTime._reactInternalFiber = workInProgress), + mountClassInstance( + workInProgress, + Component, + props, + renderExpirationTime + ), + (workInProgress = finishClassComponent( + current$$1, + workInProgress, + Component, + !0, + resolvedTag, + renderExpirationTime + ))) + : ((workInProgress.tag = 0), + reconcileChildren( + current$$1, + workInProgress, + updateExpirationTime, + renderExpirationTime + ), + (workInProgress.memoizedProps = props), + (workInProgress = workInProgress.child)); + return workInProgress; case 0: - return updateFunctionalComponent( + return updateFunctionComponent( current$$1, workInProgress, workInProgress.type, @@ -3874,17 +3938,19 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { renderExpirationTime ); case 1: - var _Component5 = workInProgress.type._reactResult; - updateExpirationTime = workInProgress.pendingProps; - current$$1 = updateFunctionalComponent( - current$$1, - workInProgress, - _Component5, - resolveDefaultProps(_Component5, updateExpirationTime), - renderExpirationTime + return ( + (props = workInProgress.type._reactResult), + (Component = workInProgress.pendingProps), + (current$$1 = updateFunctionComponent( + current$$1, + workInProgress, + props, + resolveDefaultProps(props, Component), + renderExpirationTime + )), + (workInProgress.memoizedProps = Component), + current$$1 ); - workInProgress.memoizedProps = updateExpirationTime; - return current$$1; case 2: return updateClassComponent( current$$1, @@ -3895,37 +3961,37 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { ); case 3: return ( - (_Component5 = workInProgress.type._reactResult), - (updateExpirationTime = workInProgress.pendingProps), + (props = workInProgress.type._reactResult), + (Component = workInProgress.pendingProps), (current$$1 = updateClassComponent( current$$1, workInProgress, - _Component5, - resolveDefaultProps(_Component5, updateExpirationTime), + props, + resolveDefaultProps(props, Component), renderExpirationTime )), - (workInProgress.memoizedProps = updateExpirationTime), + (workInProgress.memoizedProps = Component), current$$1 ); case 5: return ( pushHostRootContext(workInProgress), - (updateExpirationTime = workInProgress.updateQueue), + (Component = workInProgress.updateQueue), invariant( - null !== updateExpirationTime, + null !== Component, "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." ), - (_Component5 = workInProgress.memoizedState), - (_Component5 = null !== _Component5 ? _Component5.element : null), + (props = workInProgress.memoizedState), + (props = null !== props ? props.element : null), processUpdateQueue( workInProgress, - updateExpirationTime, + Component, workInProgress.pendingProps, null, renderExpirationTime ), - (updateExpirationTime = workInProgress.memoizedState.element), - updateExpirationTime === _Component5 + (Component = workInProgress.memoizedState.element), + Component === props ? (workInProgress = bailoutOnAlreadyFinishedWork( current$$1, workInProgress, @@ -3934,7 +4000,7 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { : (reconcileChildren( current$$1, workInProgress, - updateExpirationTime, + Component, renderExpirationTime ), (workInProgress = workInProgress.child)), @@ -3944,16 +4010,16 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { return ( pushHostContext(workInProgress), null === current$$1 && tryToClaimNextHydratableInstance(workInProgress), - (updateExpirationTime = workInProgress.pendingProps), - (_Component5 = updateExpirationTime.children), + (Component = workInProgress.pendingProps), + (props = Component.children), markRef(current$$1, workInProgress), reconcileChildren( current$$1, workInProgress, - _Component5, + props, renderExpirationTime ), - (workInProgress.memoizedProps = updateExpirationTime), + (workInProgress.memoizedProps = Component), (workInProgress = workInProgress.child), workInProgress ); @@ -3971,21 +4037,21 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { workInProgress, workInProgress.stateNode.containerInfo ), - (updateExpirationTime = workInProgress.pendingProps), + (Component = workInProgress.pendingProps), null === current$$1 ? (workInProgress.child = reconcileChildFibers( workInProgress, null, - updateExpirationTime, + Component, renderExpirationTime )) : reconcileChildren( current$$1, workInProgress, - updateExpirationTime, + Component, renderExpirationTime ), - (workInProgress.memoizedProps = updateExpirationTime), + (workInProgress.memoizedProps = Component), workInProgress.child ); case 13: @@ -3998,80 +4064,83 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { ); case 14: return ( - (_Component5 = workInProgress.type._reactResult), - (updateExpirationTime = workInProgress.pendingProps), + (props = workInProgress.type._reactResult), + (Component = workInProgress.pendingProps), (current$$1 = updateForwardRef( current$$1, workInProgress, - _Component5, - resolveDefaultProps(_Component5, updateExpirationTime), + props, + resolveDefaultProps(props, Component), renderExpirationTime )), - (workInProgress.memoizedProps = updateExpirationTime), + (workInProgress.memoizedProps = Component), current$$1 ); case 9: return ( - (updateExpirationTime = workInProgress.pendingProps), + (Component = workInProgress.pendingProps), reconcileChildren( current$$1, workInProgress, - updateExpirationTime, + Component, renderExpirationTime ), - (workInProgress.memoizedProps = updateExpirationTime), + (workInProgress.memoizedProps = Component), workInProgress.child ); case 10: return ( - (updateExpirationTime = workInProgress.pendingProps.children), + (Component = workInProgress.pendingProps.children), reconcileChildren( current$$1, workInProgress, - updateExpirationTime, + Component, renderExpirationTime ), - (workInProgress.memoizedProps = updateExpirationTime), + (workInProgress.memoizedProps = Component), workInProgress.child ); case 15: return ( (workInProgress.effectTag |= 4), - (updateExpirationTime = workInProgress.pendingProps), + (Component = workInProgress.pendingProps), reconcileChildren( current$$1, workInProgress, - updateExpirationTime.children, + Component.children, renderExpirationTime ), - (workInProgress.memoizedProps = updateExpirationTime), + (workInProgress.memoizedProps = Component), workInProgress.child ); case 12: a: { - updateExpirationTime = workInProgress.type._context; - _Component5 = workInProgress.pendingProps; - var oldProps = workInProgress.memoizedProps, - newValue = _Component5.value; - workInProgress.memoizedProps = _Component5; - pushProvider(workInProgress, newValue); - if (null !== oldProps) { - var oldValue = oldProps.value; - newValue = - (oldValue === newValue && - (0 !== oldValue || 1 / oldValue === 1 / newValue)) || - (oldValue !== oldValue && newValue !== newValue) - ? 0 - : ("function" === - typeof updateExpirationTime._calculateChangedBits - ? updateExpirationTime._calculateChangedBits( - oldValue, - newValue - ) - : 1073741823) | 0; - if (0 === newValue) { + Component = workInProgress.type._context; + props = workInProgress.pendingProps; + resolvedTag = workInProgress.memoizedProps; + updateExpirationTime = props.value; + workInProgress.memoizedProps = props; + pushProvider(workInProgress, updateExpirationTime); + if (null !== resolvedTag) + if ( + ((resolvedProps = resolvedTag.value), + (updateExpirationTime = + (resolvedProps === updateExpirationTime && + (0 !== resolvedProps || + 1 / resolvedProps === 1 / updateExpirationTime)) || + (resolvedProps !== resolvedProps && + updateExpirationTime !== updateExpirationTime) + ? 0 + : ("function" === typeof Component._calculateChangedBits + ? Component._calculateChangedBits( + resolvedProps, + updateExpirationTime + ) + : 1073741823) | 0), + 0 === updateExpirationTime) + ) { if ( - oldProps.children === _Component5.children && + resolvedTag.children === props.children && !didPerformWorkStackCursor.current ) { workInProgress = bailoutOnAlreadyFinishedWork( @@ -4083,87 +4152,85 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { } } else for ( - oldProps = workInProgress.child, - null !== oldProps && (oldProps.return = workInProgress); - null !== oldProps; + resolvedTag = workInProgress.child, + null !== resolvedTag && (resolvedTag.return = workInProgress); + null !== resolvedTag; ) { - oldValue = oldProps.firstContextDependency; - if (null !== oldValue) { + resolvedProps = resolvedTag.firstContextDependency; + if (null !== resolvedProps) { do { if ( - oldValue.context === updateExpirationTime && - 0 !== (oldValue.observedBits & newValue) + resolvedProps.context === Component && + 0 !== (resolvedProps.observedBits & updateExpirationTime) ) { - if (2 === oldProps.tag || 3 === oldProps.tag) { - var nextFiber = createUpdate(renderExpirationTime); - nextFiber.tag = 2; - enqueueUpdate(oldProps, nextFiber); - } + if (2 === resolvedTag.tag || 3 === resolvedTag.tag) + (child = createUpdate(renderExpirationTime)), + (child.tag = 2), + enqueueUpdate(resolvedTag, child); if ( - 0 === oldProps.expirationTime || - oldProps.expirationTime > renderExpirationTime + 0 === resolvedTag.expirationTime || + resolvedTag.expirationTime > renderExpirationTime ) - oldProps.expirationTime = renderExpirationTime; - nextFiber = oldProps.alternate; - null !== nextFiber && - (0 === nextFiber.expirationTime || - nextFiber.expirationTime > renderExpirationTime) && - (nextFiber.expirationTime = renderExpirationTime); - for (var node = oldProps.return; null !== node; ) { - nextFiber = node.alternate; + resolvedTag.expirationTime = renderExpirationTime; + child = resolvedTag.alternate; + null !== child && + (0 === child.expirationTime || + child.expirationTime > renderExpirationTime) && + (child.expirationTime = renderExpirationTime); + for (var node = resolvedTag.return; null !== node; ) { + child = node.alternate; if ( 0 === node.childExpirationTime || node.childExpirationTime > renderExpirationTime ) (node.childExpirationTime = renderExpirationTime), - null !== nextFiber && - (0 === nextFiber.childExpirationTime || - nextFiber.childExpirationTime > + null !== child && + (0 === child.childExpirationTime || + child.childExpirationTime > renderExpirationTime) && - (nextFiber.childExpirationTime = renderExpirationTime); + (child.childExpirationTime = renderExpirationTime); else if ( - null !== nextFiber && - (0 === nextFiber.childExpirationTime || - nextFiber.childExpirationTime > renderExpirationTime) + null !== child && + (0 === child.childExpirationTime || + child.childExpirationTime > renderExpirationTime) ) - nextFiber.childExpirationTime = renderExpirationTime; + child.childExpirationTime = renderExpirationTime; else break; node = node.return; } } - nextFiber = oldProps.child; - oldValue = oldValue.next; - } while (null !== oldValue); + child = resolvedTag.child; + resolvedProps = resolvedProps.next; + } while (null !== resolvedProps); } else - nextFiber = - 12 === oldProps.tag - ? oldProps.type === workInProgress.type + child = + 12 === resolvedTag.tag + ? resolvedTag.type === workInProgress.type ? null - : oldProps.child - : oldProps.child; - if (null !== nextFiber) nextFiber.return = oldProps; + : resolvedTag.child + : resolvedTag.child; + if (null !== child) child.return = resolvedTag; else - for (nextFiber = oldProps; null !== nextFiber; ) { - if (nextFiber === workInProgress) { - nextFiber = null; + for (child = resolvedTag; null !== child; ) { + if (child === workInProgress) { + child = null; break; } - oldProps = nextFiber.sibling; - if (null !== oldProps) { - oldProps.return = nextFiber.return; - nextFiber = oldProps; + resolvedTag = child.sibling; + if (null !== resolvedTag) { + resolvedTag.return = child.return; + child = resolvedTag; break; } - nextFiber = nextFiber.return; + child = child.return; } - oldProps = nextFiber; + resolvedTag = child; } - } reconcileChildren( current$$1, workInProgress, - _Component5.children, + props.children, renderExpirationTime ); workInProgress = workInProgress.child; @@ -4171,25 +4238,49 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { return workInProgress; case 11: return ( - (newValue = workInProgress.type), - (updateExpirationTime = workInProgress.pendingProps), - (_Component5 = updateExpirationTime.children), + (updateExpirationTime = workInProgress.type), + (Component = workInProgress.pendingProps), + (props = Component.children), prepareToReadContext(workInProgress, renderExpirationTime), - (newValue = readContext( - newValue, - updateExpirationTime.unstable_observedBits + (updateExpirationTime = readContext( + updateExpirationTime, + Component.unstable_observedBits )), - (_Component5 = _Component5(newValue)), + (props = props(updateExpirationTime)), (workInProgress.effectTag |= 1), reconcileChildren( current$$1, workInProgress, - _Component5, + props, renderExpirationTime ), - (workInProgress.memoizedProps = updateExpirationTime), + (workInProgress.memoizedProps = Component), workInProgress.child ); + case 17: + return updatePureComponent( + current$$1, + workInProgress, + workInProgress.type, + workInProgress.pendingProps, + updateExpirationTime, + renderExpirationTime + ); + case 18: + return ( + (props = workInProgress.type._reactResult), + (Component = workInProgress.pendingProps), + (current$$1 = updatePureComponent( + current$$1, + workInProgress, + props, + resolveDefaultProps(props, Component), + updateExpirationTime, + renderExpirationTime + )), + (workInProgress.memoizedProps = Component), + current$$1 + ); default: invariant( !1, @@ -4392,13 +4483,21 @@ function createRootErrorUpdate(fiber, errorInfo, expirationTime) { function createClassErrorUpdate(fiber, errorInfo, expirationTime) { expirationTime = createUpdate(expirationTime); expirationTime.tag = 3; + var getDerivedStateFromError = fiber.type.getDerivedStateFromError; + if ("function" === typeof getDerivedStateFromError) { + var error$jscomp$0 = errorInfo.value; + expirationTime.payload = function() { + return getDerivedStateFromError(error$jscomp$0); + }; + } var inst = fiber.stateNode; null !== inst && "function" === typeof inst.componentDidCatch && (expirationTime.callback = function() { - null === legacyErrorBoundariesThatAlreadyFailed - ? (legacyErrorBoundariesThatAlreadyFailed = new Set([this])) - : legacyErrorBoundariesThatAlreadyFailed.add(this); + "function" !== typeof getDerivedStateFromError && + (null === legacyErrorBoundariesThatAlreadyFailed + ? (legacyErrorBoundariesThatAlreadyFailed = new Set([this])) + : legacyErrorBoundariesThatAlreadyFailed.add(this)); var error = errorInfo.value, stack = errorInfo.stack; logError(fiber, errorInfo); @@ -4434,14 +4533,16 @@ function throwException( return; case 2: case 3: + returnFiber = value; + sourceFiber = root.type; + var instance = root.stateNode; if ( - ((returnFiber = value), - (sourceFiber = root.stateNode), 0 === (root.effectTag & 64) && - null !== sourceFiber && - "function" === typeof sourceFiber.componentDidCatch && - (null === legacyErrorBoundariesThatAlreadyFailed || - !legacyErrorBoundariesThatAlreadyFailed.has(sourceFiber))) + ("function" === typeof sourceFiber.getDerivedStateFromError || + (null !== instance && + "function" === typeof instance.componentDidCatch && + (null === legacyErrorBoundariesThatAlreadyFailed || + !legacyErrorBoundariesThatAlreadyFailed.has(instance)))) ) { root.effectTag |= 1024; root.expirationTime = renderExpirationTime; @@ -4509,9 +4610,9 @@ function unwindWork(workInProgress) { var Dispatcher = { readContext: readContext }, ReactCurrentOwner$2 = ReactSharedInternals.ReactCurrentOwner; invariant( - null != tracking.__interactionsRef && - null != tracking.__interactionsRef.current, - "It is not supported to run the profiling version of a renderer (for example, `react-dom/profiling`) without also replacing the `schedule/tracking` module with `schedule/tracking-profiling`. Your bundler might have a setting for aliasing both modules. Learn more at http://fb.me/react-profiling" + null != tracing.__interactionsRef && + null != tracing.__interactionsRef.current, + "It is not supported to run the profiling version of a renderer (for example, `react-dom/profiling`) without also replacing the `schedule/tracing` module with `schedule/tracing-profiling`. Your bundler might have a setting for aliasing both modules. Learn more at http://fb.me/react-profiling" ); var isWorking = !1, nextUnitOfWork = null, @@ -4520,8 +4621,7 @@ var isWorking = !1, nextRenderDidError = !1, nextEffect = null, isCommitting$1 = !1, - legacyErrorBoundariesThatAlreadyFailed = null, - suspenseDidTimeout = !1; + legacyErrorBoundariesThatAlreadyFailed = null; function resetStack() { if (null !== nextUnitOfWork) for ( @@ -4809,20 +4909,8 @@ function commitRoot(root, finishedWork) { : updateExpirationTimeBeforeCommit ); updateExpirationTimeBeforeCommit = null; - var committedInteractions = []; - updateExpirationTimeBeforeCommit = tracking.__interactionsRef.current; - tracking.__interactionsRef.current = root.memoizedInteractions; - root.pendingInteractionMap.forEach(function( - scheduledInteractions, - scheduledExpirationTime - ) { - scheduledExpirationTime <= committedExpirationTime && - (committedInteractions.push.apply( - committedInteractions, - Array.from(scheduledInteractions) - ), - root.pendingInteractionMap.delete(scheduledExpirationTime)); - }); + updateExpirationTimeBeforeCommit = tracing.__interactionsRef.current; + tracing.__interactionsRef.current = root.memoizedInteractions; ReactCurrentOwner$2.current = null; childExpirationTimeBeforeCommit = void 0; 1 < finishedWork.effectTag @@ -4886,18 +4974,19 @@ function commitRoot(root, finishedWork) { onCommitFiberRoot(finishedWork.stateNode); childExpirationTimeBeforeCommit = finishedWork.expirationTime; finishedWork = finishedWork.childExpirationTime; - finishedWork = + var earliestRemainingTimeAfterCommit = 0 === childExpirationTimeBeforeCommit || (0 !== finishedWork && finishedWork < childExpirationTimeBeforeCommit) ? finishedWork : childExpirationTimeBeforeCommit; - 0 === finishedWork && (legacyErrorBoundariesThatAlreadyFailed = null); - onCommit(root, finishedWork); - tracking.__interactionsRef.current = updateExpirationTimeBeforeCommit; + 0 === earliestRemainingTimeAfterCommit && + (legacyErrorBoundariesThatAlreadyFailed = null); + onCommit(root, earliestRemainingTimeAfterCommit); + tracing.__interactionsRef.current = updateExpirationTimeBeforeCommit; var subscriber = void 0; try { if ( - ((subscriber = tracking.__subscriberRef.current), + ((subscriber = tracing.__subscriberRef.current), null !== subscriber && 0 < root.memoizedInteractions.size) ) subscriber.onWorkStopped( @@ -4907,17 +4996,27 @@ function commitRoot(root, finishedWork) { } catch (error) { hasUnhandledError || ((hasUnhandledError = !0), (unhandledError = error)); } finally { - suspenseDidTimeout || - committedInteractions.forEach(function(interaction) { - interaction.__count--; - if (null !== subscriber && 0 === interaction.__count) - try { - subscriber.onInteractionScheduledWorkCompleted(interaction); - } catch (error) { - hasUnhandledError || - ((hasUnhandledError = !0), (unhandledError = error)); - } - }); + var pendingInteractionMap = root.pendingInteractionMap; + pendingInteractionMap.forEach(function( + scheduledInteractions, + scheduledExpirationTime + ) { + if ( + 0 === earliestRemainingTimeAfterCommit || + scheduledExpirationTime < earliestRemainingTimeAfterCommit + ) + pendingInteractionMap.delete(scheduledExpirationTime), + scheduledInteractions.forEach(function(interaction) { + interaction.__count--; + if (null !== subscriber && 0 === interaction.__count) + try { + subscriber.onInteractionScheduledWorkCompleted(interaction); + } catch (error) { + hasUnhandledError || + ((hasUnhandledError = !0), (unhandledError = error)); + } + }); + }); } } function completeUnitOfWork(workInProgress) { @@ -5051,6 +5150,9 @@ function completeUnitOfWork(workInProgress) { break; case 11: break; + case 17: + case 18: + break; case 4: invariant( !1, @@ -5065,63 +5167,53 @@ function completeUnitOfWork(workInProgress) { nextUnitOfWork = null; workInProgress.mode & 4 && stopProfilerTimerIfRunningAndRecordDelta(workInProgress, !1); - current$$1 = nextUnitOfWork; - fiber = workInProgress; + current$$1 = workInProgress; if ( 1073741823 === nextRenderExpirationTime || - 1073741823 !== fiber.childExpirationTime + 1073741823 !== current$$1.childExpirationTime ) { - rootContainerInstance = 0; - if (fiber.mode & 4) { - current = fiber.actualDuration; - viewConfig = fiber.selfBaseDuration; - type = - null === fiber.alternate || fiber.child !== fiber.alternate.child; - for ( - internalInstanceHandle = fiber.child; - null !== internalInstanceHandle; - - ) { - currentHostContext = internalInstanceHandle.expirationTime; - var childChildExpirationTime = - internalInstanceHandle.childExpirationTime; + fiber = 0; + if (current$$1.mode & 4) { + rootContainerInstance = current$$1.actualDuration; + current = current$$1.selfBaseDuration; + viewConfig = + null === current$$1.alternate || + current$$1.child !== current$$1.alternate.child; + for (type = current$$1.child; null !== type; ) { + internalInstanceHandle = type.expirationTime; + currentHostContext = type.childExpirationTime; if ( - 0 === rootContainerInstance || - (0 !== currentHostContext && - currentHostContext < rootContainerInstance) + 0 === fiber || + (0 !== internalInstanceHandle && internalInstanceHandle < fiber) ) - rootContainerInstance = currentHostContext; + fiber = internalInstanceHandle; if ( - 0 === rootContainerInstance || - (0 !== childChildExpirationTime && - childChildExpirationTime < rootContainerInstance) + 0 === fiber || + (0 !== currentHostContext && currentHostContext < fiber) ) - rootContainerInstance = childChildExpirationTime; - type && (current += internalInstanceHandle.actualDuration); - viewConfig += internalInstanceHandle.treeBaseDuration; - internalInstanceHandle = internalInstanceHandle.sibling; + fiber = currentHostContext; + viewConfig && (rootContainerInstance += type.actualDuration); + current += type.treeBaseDuration; + type = type.sibling; } - fiber.actualDuration = current; - fiber.treeBaseDuration = viewConfig; + current$$1.actualDuration = rootContainerInstance; + current$$1.treeBaseDuration = current; } else - for (current = fiber.child; null !== current; ) { - viewConfig = current.expirationTime; - type = current.childExpirationTime; - if ( - 0 === rootContainerInstance || - (0 !== viewConfig && viewConfig < rootContainerInstance) - ) - rootContainerInstance = viewConfig; - if ( - 0 === rootContainerInstance || - (0 !== type && type < rootContainerInstance) - ) - rootContainerInstance = type; - current = current.sibling; + for ( + rootContainerInstance = current$$1.child; + null !== rootContainerInstance; + + ) { + current = rootContainerInstance.expirationTime; + viewConfig = rootContainerInstance.childExpirationTime; + if (0 === fiber || (0 !== current && current < fiber)) + fiber = current; + if (0 === fiber || (0 !== viewConfig && viewConfig < fiber)) + fiber = viewConfig; + rootContainerInstance = rootContainerInstance.sibling; } - fiber.childExpirationTime = rootContainerInstance; + current$$1.childExpirationTime = fiber; } - if (null !== current$$1) return current$$1; null !== returnFiber && 0 === (returnFiber.effectTag & 512) && (null === returnFiber.firstEffect && @@ -5180,10 +5272,7 @@ function renderRoot(root, isYieldy, isExpired) { ); isWorking = !0; ReactCurrentOwner$2.currentDispatcher = Dispatcher; - var expirationTime = root.nextExpirationTimeToWorkOn, - prevInteractions = null; - prevInteractions = tracking.__interactionsRef.current; - tracking.__interactionsRef.current = root.memoizedInteractions; + var expirationTime = root.nextExpirationTimeToWorkOn; if ( expirationTime !== nextRenderExpirationTime || root !== nextRoot || @@ -5210,7 +5299,7 @@ function renderRoot(root, isYieldy, isExpired) { }); root.memoizedInteractions = interactions; if (0 < interactions.size) { - var subscriber = tracking.__subscriberRef.current; + var subscriber = tracing.__subscriberRef.current; if (null !== subscriber) { var threadID = 1e3 * expirationTime + root.interactionThreadID; try { @@ -5222,7 +5311,10 @@ function renderRoot(root, isYieldy, isExpired) { } } } - subscriber = !1; + subscriber = null; + subscriber = tracing.__interactionsRef.current; + tracing.__interactionsRef.current = root.memoizedInteractions; + threadID = !1; do { try { if (isYieldy) @@ -5233,35 +5325,34 @@ function renderRoot(root, isYieldy, isExpired) { nextUnitOfWork = performUnitOfWork(nextUnitOfWork); } catch (thrownValue) { if (null === nextUnitOfWork) - (subscriber = !0), onUncaughtError(thrownValue); + (threadID = !0), onUncaughtError(thrownValue); else { invariant( null !== nextUnitOfWork, "Failed to replay rendering after an error. This is likely caused by a bug in React. Please file an issue with a reproducing case to help us find it." ); - threadID = nextUnitOfWork; - var returnFiber = threadID.return; - if (null === returnFiber) - (subscriber = !0), onUncaughtError(thrownValue); + var sourceFiber = nextUnitOfWork, + returnFiber = sourceFiber.return; + if (null === returnFiber) (threadID = !0), onUncaughtError(thrownValue); else { throwException( root, returnFiber, - threadID, + sourceFiber, thrownValue, nextRenderExpirationTime ); - nextUnitOfWork = completeUnitOfWork(threadID); + nextUnitOfWork = completeUnitOfWork(sourceFiber); continue; } } } break; } while (1); - tracking.__interactionsRef.current = prevInteractions; + tracing.__interactionsRef.current = subscriber; isWorking = !1; lastContextWithAllBitsObserved = lastContextDependency = currentlyRenderingFiber = ReactCurrentOwner$2.currentDispatcher = null; - if (subscriber) (nextRoot = null), (root.finishedWork = null); + if (threadID) (nextRoot = null), (root.finishedWork = null); else if (null !== nextUnitOfWork) root.finishedWork = null; else { isYieldy = root.current.alternate; @@ -5279,8 +5370,8 @@ function renderRoot(root, isYieldy, isExpired) { if (!root.didError && !isExpired) { root.didError = !0; isExpired = root.nextExpirationTimeToWorkOn = expirationTime; - prevInteractions = root.expirationTime = 1; - onSuspend(root, isYieldy, isExpired, prevInteractions, -1); + subscriber = root.expirationTime = 1; + onSuspend(root, isYieldy, isExpired, subscriber, -1); return; } } @@ -5305,7 +5396,7 @@ function captureCommitPhaseError(fiber, error) { var instance = JSCompiler_inline_result.stateNode; if ( "function" === - typeof JSCompiler_inline_result.type.getDerivedStateFromCatch || + typeof JSCompiler_inline_result.type.getDerivedStateFromError || ("function" === typeof instance.componentDidCatch && (null === legacyErrorBoundariesThatAlreadyFailed || !legacyErrorBoundariesThatAlreadyFailed.has(instance))) @@ -5353,102 +5444,96 @@ function computeExpirationForFiber(currentTime, fiber) { (currentTime += 1)) : (currentTime = 1); isBatchingInteractiveUpdates && - (0 === lowestPriorityPendingInteractiveExpirationTime || - currentTime > lowestPriorityPendingInteractiveExpirationTime) && + currentTime > lowestPriorityPendingInteractiveExpirationTime && (lowestPriorityPendingInteractiveExpirationTime = currentTime); return currentTime; } -function storeInteractionsForExpirationTime( - root, - expirationTime, - updateInteractionCounts -) { - var interactions = tracking.__interactionsRef.current; - if (0 < interactions.size) { - var pendingInteractions = root.pendingInteractionMap.get(expirationTime); +function scheduleWorkToRoot(fiber, expirationTime) { + if (0 === fiber.expirationTime || fiber.expirationTime > expirationTime) + fiber.expirationTime = expirationTime; + var alternate = fiber.alternate; + null !== alternate && + (0 === alternate.expirationTime || + alternate.expirationTime > expirationTime) && + (alternate.expirationTime = expirationTime); + var node = fiber.return, + root = null; + if (null === node && 5 === fiber.tag) root = fiber.stateNode; + else + for (; null !== node; ) { + alternate = node.alternate; + if ( + 0 === node.childExpirationTime || + node.childExpirationTime > expirationTime + ) + node.childExpirationTime = expirationTime; + null !== alternate && + (0 === alternate.childExpirationTime || + alternate.childExpirationTime > expirationTime) && + (alternate.childExpirationTime = expirationTime); + if (null === node.return && 5 === node.tag) { + root = node.stateNode; + break; + } + node = node.return; + } + if (null === root) return null; + fiber = tracing.__interactionsRef.current; + if (0 < fiber.size) { + alternate = root.pendingInteractionMap; + var pendingInteractions = alternate.get(expirationTime); null != pendingInteractions - ? interactions.forEach(function(interaction) { - updateInteractionCounts && - !pendingInteractions.has(interaction) && - interaction.__count++; + ? fiber.forEach(function(interaction) { + pendingInteractions.has(interaction) || interaction.__count++; pendingInteractions.add(interaction); }) - : (root.pendingInteractionMap.set(expirationTime, new Set(interactions)), - updateInteractionCounts && - interactions.forEach(function(interaction) { - interaction.__count++; - })); - var subscriber = tracking.__subscriberRef.current; - if (null !== subscriber) - subscriber.onWorkScheduled( - interactions, + : (alternate.set(expirationTime, new Set(fiber)), + fiber.forEach(function(interaction) { + interaction.__count++; + })); + alternate = tracing.__subscriberRef.current; + if (null !== alternate) + alternate.onWorkScheduled( + fiber, 1e3 * expirationTime + root.interactionThreadID ); } + return root; } function scheduleWork(fiber, expirationTime) { - a: { - if (0 === fiber.expirationTime || fiber.expirationTime > expirationTime) - fiber.expirationTime = expirationTime; - var alternate = fiber.alternate; - null !== alternate && - (0 === alternate.expirationTime || - alternate.expirationTime > expirationTime) && - (alternate.expirationTime = expirationTime); - var node = fiber.return; - if (null === node && 5 === fiber.tag) fiber = fiber.stateNode; - else { - for (; null !== node; ) { - alternate = node.alternate; - if ( - 0 === node.childExpirationTime || - node.childExpirationTime > expirationTime - ) - node.childExpirationTime = expirationTime; - null !== alternate && - (0 === alternate.childExpirationTime || - alternate.childExpirationTime > expirationTime) && - (alternate.childExpirationTime = expirationTime); - if (null === node.return && 5 === node.tag) { - fiber = node.stateNode; - break a; - } - node = node.return; - } - fiber = null; - } - } + fiber = scheduleWorkToRoot(fiber, expirationTime); if (null !== fiber) { - storeInteractionsForExpirationTime(fiber, expirationTime, !0); !isWorking && 0 !== nextRenderExpirationTime && expirationTime < nextRenderExpirationTime && resetStack(); markPendingPriorityLevel(fiber, expirationTime); if (!isWorking || isCommitting$1 || nextRoot !== fiber) { - expirationTime = fiber; - fiber = fiber.expirationTime; - if (null === expirationTime.nextScheduledRoot) - (expirationTime.expirationTime = fiber), + expirationTime = fiber.expirationTime; + if (null === fiber.nextScheduledRoot) + (fiber.expirationTime = expirationTime), null === lastScheduledRoot - ? ((firstScheduledRoot = lastScheduledRoot = expirationTime), - (expirationTime.nextScheduledRoot = expirationTime)) - : ((lastScheduledRoot = lastScheduledRoot.nextScheduledRoot = expirationTime), + ? ((firstScheduledRoot = lastScheduledRoot = fiber), + (fiber.nextScheduledRoot = fiber)) + : ((lastScheduledRoot = lastScheduledRoot.nextScheduledRoot = fiber), (lastScheduledRoot.nextScheduledRoot = firstScheduledRoot)); - else if ( - ((alternate = expirationTime.expirationTime), - 0 === alternate || fiber < alternate) - ) - expirationTime.expirationTime = fiber; + else { + var remainingExpirationTime = fiber.expirationTime; + if ( + 0 === remainingExpirationTime || + expirationTime < remainingExpirationTime + ) + fiber.expirationTime = expirationTime; + } isRendering || (isBatchingUpdates ? isUnbatchingUpdates && - ((nextFlushedRoot = expirationTime), + ((nextFlushedRoot = fiber), (nextFlushedExpirationTime = 1), - performWorkOnRoot(expirationTime, 1, !0)) - : 1 === fiber + performWorkOnRoot(fiber, 1, !0)) + : 1 === expirationTime ? performWork(1, null) - : scheduleCallbackWithExpirationTime(expirationTime, fiber)); + : scheduleCallbackWithExpirationTime(fiber, expirationTime)); } nestedUpdateCount > NESTED_UPDATE_LIMIT && ((nestedUpdateCount = 0), @@ -5961,7 +6046,7 @@ var roots = new Map(), expirationTime: 0, firstBatch: null, nextScheduledRoot: null, - interactionThreadID: tracking.unstable_getThreadID(), + interactionThreadID: tracing.unstable_getThreadID(), memoizedInteractions: new Set(), pendingInteractionMap: new Map() }; @@ -6068,7 +6153,7 @@ var roots = new Map(), findFiberByHostInstance: getInstanceFromInstance, getInspectorDataForViewTag: getInspectorDataForViewTag, bundleType: 0, - version: "16.5.0", + version: "16.5.2", rendererPackageName: "react-native-renderer" }); var ReactFabric$2 = { default: ReactFabric }, diff --git a/Libraries/Renderer/oss/ReactNativeRenderer-dev.js b/Libraries/Renderer/oss/ReactNativeRenderer-dev.js index b3fdfc9aebd3aa..4108f0d42c519c 100644 --- a/Libraries/Renderer/oss/ReactNativeRenderer-dev.js +++ b/Libraries/Renderer/oss/ReactNativeRenderer-dev.js @@ -26,7 +26,7 @@ var deepDiffer = require("deepDiffer"); var flattenStyle = require("flattenStyle"); var TextInputState = require("TextInputState"); var checkPropTypes = require("prop-types/checkPropTypes"); -var tracking = require("schedule/tracking"); +var tracing = require("scheduler/tracing"); var ExceptionsManager = require("ExceptionsManager"); /** @@ -165,6 +165,13 @@ var invokeGuardedCallbackImpl = function( // browsers that support it. var windowEvent = window.event; + // Keeps track of the descriptor of window.event to restore it after event + // dispatching: https://github.com/facebook/react/issues/13688 + var windowEventDescriptor = Object.getOwnPropertyDescriptor( + window, + "event" + ); + // Create an event handler for our fake event. We will synchronously // dispatch our fake event using `dispatchEvent`. Inside the handler, we // call the user-provided callback. @@ -239,6 +246,10 @@ var invokeGuardedCallbackImpl = function( evt.initEvent(evtType, false, false); fakeNode.dispatchEvent(evt); + if (windowEventDescriptor) { + Object.defineProperty(window, "event", windowEventDescriptor); + } + if (didError) { if (!didSetError) { // The callback errored, but the error event never fired. @@ -606,31 +617,77 @@ var warningWithoutStack = function() {}; "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 _console; - - var stringArgs = args.map(function(item) { - return "" + item; - }); - (_console = console).error.apply( - _console, - ["Warning: " + format].concat(stringArgs) - ); + var _args$map = args.map(function(item) { + return "" + item; + }), + a = _args$map[0], + b = _args$map[1], + c = _args$map[2], + d = _args$map[3], + e = _args$map[4], + f = _args$map[5], + g = _args$map[6], + h = _args$map[7]; + + var message = "Warning: " + format; + + // We intentionally don't use spread (or .apply) because it breaks IE9: + // https://github.com/facebook/react/issues/13610 + switch (args.length) { + case 0: + console.error(message); + break; + case 1: + console.error(message, a); + break; + case 2: + console.error(message, a, b); + break; + case 3: + console.error(message, a, b, c); + break; + case 4: + console.error(message, a, b, c, d); + break; + case 5: + console.error(message, a, b, c, d, e); + break; + case 6: + console.error(message, a, b, c, d, e, f); + break; + case 7: + console.error(message, a, b, c, d, e, f, g); + break; + case 8: + console.error(message, a, b, c, d, e, f, g, h); + break; + default: + throw new Error( + "warningWithoutStack() currently supports at most 8 arguments." + ); + } } 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 = + var _message = "Warning: " + format.replace(/%s/g, function() { return args[argIndex++]; }); - throw new Error(message); + throw new Error(_message); } catch (x) {} }; } @@ -1075,11 +1132,11 @@ function runExtractedEventsInBatch( runEventsInBatch(events, false); } -var FunctionalComponent = 0; -var FunctionalComponentLazy = 1; +var FunctionComponent = 0; +var FunctionComponentLazy = 1; var ClassComponent = 2; var ClassComponentLazy = 3; -var IndeterminateComponent = 4; // Before we know whether it is functional or class +var IndeterminateComponent = 4; // Before we know whether it is function or class var HostRoot = 5; // Root of a host tree. Could be nested inside another node. var HostPortal = 6; // A subtree. Could be an entry point to a different renderer. var HostComponent = 7; @@ -1092,6 +1149,8 @@ var ForwardRef = 13; var ForwardRefLazy = 14; var Profiler = 15; var PlaceholderComponent = 16; +var PureComponent = 17; +var PureComponentLazy = 18; function getParent(inst) { do { @@ -2864,13 +2923,16 @@ var REACT_STRICT_MODE_TYPE = hasSymbol var REACT_PROFILER_TYPE = hasSymbol ? Symbol.for("react.profiler") : 0xead2; var REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for("react.provider") : 0xeacd; var REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for("react.context") : 0xeace; -var REACT_ASYNC_MODE_TYPE = hasSymbol ? Symbol.for("react.async_mode") : 0xeacf; +var REACT_CONCURRENT_MODE_TYPE = hasSymbol + ? Symbol.for("react.concurrent_mode") + : 0xeacf; var REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for("react.forward_ref") : 0xead0; var REACT_PLACEHOLDER_TYPE = hasSymbol ? Symbol.for("react.placeholder") : 0xead1; +var REACT_PURE_TYPE = hasSymbol ? Symbol.for("react.pure") : 0xead3; var MAYBE_ITERATOR_SYMBOL = typeof Symbol === "function" && Symbol.iterator; var FAUX_ITERATOR_SYMBOL = "@@iterator"; @@ -2921,8 +2983,8 @@ function getComponentName(type) { return type; } switch (type) { - case REACT_ASYNC_MODE_TYPE: - return "AsyncMode"; + case REACT_CONCURRENT_MODE_TYPE: + return "ConcurrentMode"; case REACT_FRAGMENT_TYPE: return "Fragment"; case REACT_PORTAL_TYPE: @@ -2943,9 +3005,12 @@ function getComponentName(type) { case REACT_FORWARD_REF_TYPE: var renderFn = type.render; var functionName = renderFn.displayName || renderFn.name || ""; - return functionName !== "" - ? "ForwardRef(" + functionName + ")" - : "ForwardRef"; + return ( + type.displayName || + (functionName !== "" + ? "ForwardRef(" + functionName + ")" + : "ForwardRef") + ); } if (typeof type.then === "function") { var thenable = type; @@ -4295,8 +4360,8 @@ var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame; function describeFiber(fiber) { switch (fiber.tag) { case IndeterminateComponent: - case FunctionalComponent: - case FunctionalComponentLazy: + case FunctionComponent: + case FunctionComponentLazy: case ClassComponent: case ClassComponentLazy: case HostComponent: @@ -4376,14 +4441,12 @@ function setCurrentPhase(lifeCyclePhase) { var debugRenderPhaseSideEffects = false; var debugRenderPhaseSideEffectsForStrictMode = false; -var enableGetDerivedStateFromCatch = false; var enableSuspense = false; var enableUserTimingAPI = true; var replayFailedUnitOfWorkWithInvokeGuardedCallback = true; var warnAboutDeprecatedLifecycles = false; -var warnAboutLegacyContextAPI = false; var enableProfilerTimer = true; -var enableSchedulerTracking = true; +var enableSchedulerTracing = true; // Only used in www builds. @@ -5335,7 +5398,7 @@ function computeInteractiveExpiration(currentTime) { } var NoContext = 0; -var AsyncMode = 1; +var ConcurrentMode = 1; var StrictMode = 2; var ProfileMode = 4; @@ -5447,13 +5510,15 @@ function resolveLazyComponentTag(fiber, Component) { if (typeof Component === "function") { return shouldConstruct(Component) ? ClassComponentLazy - : FunctionalComponentLazy; - } else if ( - Component !== undefined && - Component !== null && - Component.$$typeof - ) { - return ForwardRefLazy; + : FunctionComponentLazy; + } else if (Component !== undefined && Component !== null) { + var $$typeof = Component.$$typeof; + if ($$typeof === REACT_FORWARD_REF_TYPE) { + return ForwardRefLazy; + } + if ($$typeof === REACT_PURE_TYPE) { + return PureComponentLazy; + } } return IndeterminateComponent; } @@ -5507,15 +5572,8 @@ function createWorkInProgress(current, pendingProps, expirationTime) { } } - // Don't touching the subtree's expiration time, which has not changed. workInProgress.childExpirationTime = current.childExpirationTime; - if (pendingProps !== current.pendingProps) { - // This fiber has new props. - workInProgress.expirationTime = expirationTime; - } else { - // This fiber's props have not changed. - workInProgress.expirationTime = current.expirationTime; - } + workInProgress.expirationTime = current.expirationTime; workInProgress.child = current.child; workInProgress.memoizedProps = current.memoizedProps; @@ -5536,8 +5594,8 @@ function createWorkInProgress(current, pendingProps, expirationTime) { return workInProgress; } -function createHostRootFiber(isAsync) { - var mode = isAsync ? AsyncMode | StrictMode : NoContext; +function createHostRootFiber(isConcurrent) { + var mode = isConcurrent ? ConcurrentMode | StrictMode : NoContext; if (enableProfilerTimer && isDevToolsPresent) { // Always collect profile timings when DevTools are present. @@ -5574,9 +5632,9 @@ function createFiberFromElement(element, mode, expirationTime) { expirationTime, key ); - case REACT_ASYNC_MODE_TYPE: + case REACT_CONCURRENT_MODE_TYPE: fiberTag = Mode; - mode |= AsyncMode | StrictMode; + mode |= ConcurrentMode | StrictMode; break; case REACT_STRICT_MODE_TYPE: fiberTag = Mode; @@ -5600,6 +5658,9 @@ function createFiberFromElement(element, mode, expirationTime) { case REACT_FORWARD_REF_TYPE: fiberTag = ForwardRef; break getTag; + case REACT_PURE_TYPE: + fiberTag = PureComponent; + break getTag; default: { if (typeof type.then === "function") { fiberTag = IndeterminateComponent; @@ -5749,29 +5810,26 @@ function assignFiberPropertiesInDEV(target, source) { return target; } -/* eslint-disable no-use-before-define */ // TODO: This should be lifted into the renderer. -// The following attributes are only used by interaction tracking builds. +// The following attributes are only used by interaction tracing builds. // They enable interactions to be associated with their async work, // And expose interaction metadata to the React DevTools Profiler plugin. -// Note that these attributes are only defined when the enableSchedulerTracking flag is enabled. +// Note that these attributes are only defined when the enableSchedulerTracing flag is enabled. // Exported FiberRoot type includes all properties, // To avoid requiring potentially error-prone :any casts throughout the project. -// Profiling properties are only safe to access in profiling builds (when enableSchedulerTracking is true). +// Profiling properties are only safe to access in profiling builds (when enableSchedulerTracing is true). // The types are defined separately within this file to ensure they stay in sync. -// (We don't have to use an inline :any cast when enableSchedulerTracking is disabled.) - -/* eslint-enable no-use-before-define */ +// (We don't have to use an inline :any cast when enableSchedulerTracing is disabled.) -function createFiberRoot(containerInfo, isAsync, hydrate) { +function createFiberRoot(containerInfo, isConcurrent, hydrate) { // Cyclic construction. This cheats the type system right now because // stateNode is any. - var uninitializedFiber = createHostRootFiber(isAsync); + var uninitializedFiber = createHostRootFiber(isConcurrent); var root = void 0; - if (enableSchedulerTracking) { + if (enableSchedulerTracing) { root = { current: uninitializedFiber, containerInfo: containerInfo, @@ -5796,7 +5854,7 @@ function createFiberRoot(containerInfo, isAsync, hydrate) { firstBatch: null, nextScheduledRoot: null, - interactionThreadID: tracking.unstable_getThreadID(), + interactionThreadID: tracing.unstable_getThreadID(), memoizedInteractions: new Set(), pendingInteractionMap: new Map() }; @@ -5830,8 +5888,8 @@ function createFiberRoot(containerInfo, isAsync, hydrate) { uninitializedFiber.stateNode = root; // The reason for the way the Flow types are structured in this file, - // Is to avoid needing :any casts everywhere interaction tracking fields are used. - // Unfortunately that requires an :any cast for non-interaction tracking capable builds. + // Is to avoid needing :any casts everywhere interaction tracing fields are used. + // Unfortunately that requires an :any cast for non-interaction tracing capable builds. // $FlowFixMe Remove this :any cast and replace it with something better. return root; } @@ -7562,7 +7620,7 @@ function shallowEqual(objA, objB) { } var fakeInternalInstance = {}; -var isArray = Array.isArray; +var isArray$1 = Array.isArray; // React.Component uses a shared frozen object by default. // We'll use it to determine whether we need to initialize legacy refs. @@ -7576,6 +7634,8 @@ var didWarnAboutUndefinedDerivedState = void 0; var warnOnUndefinedDerivedState = void 0; var warnOnInvalidCallback = void 0; var didWarnAboutDirectlyAssigningPropsToState = void 0; +var didWarnAboutContextTypeAndContextTypes = void 0; +var didWarnAboutInvalidateContextType = void 0; { didWarnAboutStateAssignmentForComponent = new Set(); @@ -7584,6 +7644,8 @@ var didWarnAboutDirectlyAssigningPropsToState = void 0; didWarnAboutLegacyLifecyclesAndDerivedState = new Set(); didWarnAboutDirectlyAssigningPropsToState = new Set(); didWarnAboutUndefinedDerivedState = new Set(); + didWarnAboutContextTypeAndContextTypes = new Set(); + didWarnAboutInvalidateContextType = new Set(); var didWarnOnInvalidCallback = new Set(); @@ -7745,7 +7807,7 @@ function checkShouldComponentUpdate( newProps, oldState, newState, - nextLegacyContext + nextContext ) { var instance = workInProgress.stateNode; if (typeof instance.shouldComponentUpdate === "function") { @@ -7753,7 +7815,7 @@ function checkShouldComponentUpdate( var shouldUpdate = instance.shouldComponentUpdate( newProps, newState, - nextLegacyContext + nextContext ); stopPhaseTimer(); @@ -7838,6 +7900,15 @@ function checkClassInstance(workInProgress, ctor, newProps) { 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; var noInstanceContextTypes = !instance.contextTypes; !noInstanceContextTypes ? warningWithoutStack$1( @@ -7847,6 +7918,21 @@ function checkClassInstance(workInProgress, ctor, newProps) { name ) : void 0; + + if ( + ctor.contextType && + ctor.contextTypes && + !didWarnAboutContextTypeAndContextTypes.has(ctor) + ) { + didWarnAboutContextTypeAndContextTypes.add(ctor); + warningWithoutStack$1( + false, + "%s declares both contextTypes and contextType static properties. " + + "The legacy contextTypes property will be ignored.", + name + ); + } + var noComponentShouldUpdate = typeof instance.componentShouldUpdate !== "function"; !noComponentShouldUpdate @@ -7962,11 +8048,11 @@ function checkClassInstance(workInProgress, ctor, newProps) { ) : void 0; var noInstanceGetDerivedStateFromCatch = - typeof instance.getDerivedStateFromCatch !== "function"; + typeof instance.getDerivedStateFromError !== "function"; !noInstanceGetDerivedStateFromCatch ? warningWithoutStack$1( false, - "%s: getDerivedStateFromCatch() is defined as an instance method " + + "%s: getDerivedStateFromError() is defined as an instance method " + "and will be ignored. Instead, declare it as a static method.", name ) @@ -7982,7 +8068,7 @@ function checkClassInstance(workInProgress, ctor, newProps) { ) : void 0; var _state = instance.state; - if (_state && (typeof _state !== "object" || isArray(_state))) { + if (_state && (typeof _state !== "object" || isArray$1(_state))) { warningWithoutStack$1( false, "%s.state: must be set to an object or null", @@ -8018,12 +8104,37 @@ function constructClassInstance( props, renderExpirationTime ) { - var unmaskedContext = getUnmaskedContext(workInProgress, ctor, true); - var contextTypes = ctor.contextTypes; - var isContextConsumer = contextTypes !== null && contextTypes !== undefined; - var context = isContextConsumer - ? getMaskedContext(workInProgress, unmaskedContext) - : emptyContextObject; + var isLegacyContextConsumer = false; + var unmaskedContext = emptyContextObject; + var context = null; + var contextType = ctor.contextType; + if (typeof contextType === "object" && contextType !== null) { + { + if ( + typeof contextType.unstable_read !== "function" && + !didWarnAboutInvalidateContextType.has(ctor) + ) { + didWarnAboutInvalidateContextType.add(ctor); + warningWithoutStack$1( + false, + "%s defines an invalid contextType. " + + "contextType should point to the Context object returned by React.createContext(). " + + "Did you accidentally pass the Context.Provider instead?", + getComponentName(ctor) || "Component" + ); + } + } + + context = contextType.unstable_read(); + } else { + unmaskedContext = getUnmaskedContext(workInProgress, ctor, true); + var contextTypes = ctor.contextTypes; + isLegacyContextConsumer = + contextTypes !== null && contextTypes !== undefined; + context = isLegacyContextConsumer + ? getMaskedContext(workInProgress, unmaskedContext) + : emptyContextObject; + } // Instantiate twice to help detect side-effects. { @@ -8130,7 +8241,7 @@ function constructClassInstance( // Cache unmasked context so we can avoid recreating masked context unless necessary. // ReactFiberContext usually updates this cache but can't for newly-created instances. - if (isContextConsumer) { + if (isLegacyContextConsumer) { cacheContext(workInProgress, unmaskedContext, context); } @@ -8168,15 +8279,15 @@ function callComponentWillReceiveProps( workInProgress, instance, newProps, - nextLegacyContext + nextContext ) { var oldState = instance.state; startPhaseTimer(workInProgress, "componentWillReceiveProps"); if (typeof instance.componentWillReceiveProps === "function") { - instance.componentWillReceiveProps(newProps, nextLegacyContext); + instance.componentWillReceiveProps(newProps, nextContext); } if (typeof instance.UNSAFE_componentWillReceiveProps === "function") { - instance.UNSAFE_componentWillReceiveProps(newProps, nextLegacyContext); + instance.UNSAFE_componentWillReceiveProps(newProps, nextContext); } stopPhaseTimer(); @@ -8210,12 +8321,17 @@ function mountClassInstance( } var instance = workInProgress.stateNode; - var unmaskedContext = getUnmaskedContext(workInProgress, ctor, true); - instance.props = newProps; instance.state = workInProgress.memoizedState; instance.refs = emptyRefsObject; - instance.context = getMaskedContext(workInProgress, unmaskedContext); + + var contextType = ctor.contextType; + if (typeof contextType === "object" && contextType !== null) { + instance.context = contextType.unstable_read(); + } else { + var unmaskedContext = getUnmaskedContext(workInProgress, ctor, true); + instance.context = getMaskedContext(workInProgress, unmaskedContext); + } { if (instance.state === newProps) { @@ -8316,15 +8432,18 @@ function resumeMountClassInstance( instance.props = oldProps; var oldContext = instance.context; - var nextLegacyUnmaskedContext = getUnmaskedContext( - workInProgress, - ctor, - true - ); - var nextLegacyContext = getMaskedContext( - workInProgress, - nextLegacyUnmaskedContext - ); + var contextType = ctor.contextType; + var nextContext = void 0; + if (typeof contextType === "object" && contextType !== null) { + nextContext = contextType.unstable_read(); + } else { + var nextLegacyUnmaskedContext = getUnmaskedContext( + workInProgress, + ctor, + true + ); + nextContext = getMaskedContext(workInProgress, nextLegacyUnmaskedContext); + } var getDerivedStateFromProps = ctor.getDerivedStateFromProps; var hasNewLifecycles = @@ -8342,12 +8461,12 @@ function resumeMountClassInstance( (typeof instance.UNSAFE_componentWillReceiveProps === "function" || typeof instance.componentWillReceiveProps === "function") ) { - if (oldProps !== newProps || oldContext !== nextLegacyContext) { + if (oldProps !== newProps || oldContext !== nextContext) { callComponentWillReceiveProps( workInProgress, instance, newProps, - nextLegacyContext + nextContext ); } } @@ -8400,7 +8519,7 @@ function resumeMountClassInstance( newProps, oldState, newState, - nextLegacyContext + nextContext ); if (shouldUpdate) { @@ -8440,7 +8559,7 @@ function resumeMountClassInstance( // if shouldComponentUpdate returns false. instance.props = newProps; instance.state = newState; - instance.context = nextLegacyContext; + instance.context = nextContext; return shouldUpdate; } @@ -8459,15 +8578,14 @@ function updateClassInstance( instance.props = oldProps; var oldContext = instance.context; - var nextLegacyUnmaskedContext = getUnmaskedContext( - workInProgress, - ctor, - true - ); - var nextLegacyContext = getMaskedContext( - workInProgress, - nextLegacyUnmaskedContext - ); + var contextType = ctor.contextType; + var nextContext = void 0; + if (typeof contextType === "object" && contextType !== null) { + nextContext = contextType.unstable_read(); + } else { + var nextUnmaskedContext = getUnmaskedContext(workInProgress, ctor, true); + nextContext = getMaskedContext(workInProgress, nextUnmaskedContext); + } var getDerivedStateFromProps = ctor.getDerivedStateFromProps; var hasNewLifecycles = @@ -8485,12 +8603,12 @@ function updateClassInstance( (typeof instance.UNSAFE_componentWillReceiveProps === "function" || typeof instance.componentWillReceiveProps === "function") ) { - if (oldProps !== newProps || oldContext !== nextLegacyContext) { + if (oldProps !== newProps || oldContext !== nextContext) { callComponentWillReceiveProps( workInProgress, instance, newProps, - nextLegacyContext + nextContext ); } } @@ -8557,7 +8675,7 @@ function updateClassInstance( newProps, oldState, newState, - nextLegacyContext + nextContext ); if (shouldUpdate) { @@ -8570,14 +8688,10 @@ function updateClassInstance( ) { startPhaseTimer(workInProgress, "componentWillUpdate"); if (typeof instance.componentWillUpdate === "function") { - instance.componentWillUpdate(newProps, newState, nextLegacyContext); + instance.componentWillUpdate(newProps, newState, nextContext); } if (typeof instance.UNSAFE_componentWillUpdate === "function") { - instance.UNSAFE_componentWillUpdate( - newProps, - newState, - nextLegacyContext - ); + instance.UNSAFE_componentWillUpdate(newProps, newState, nextContext); } stopPhaseTimer(); } @@ -8617,7 +8731,7 @@ function updateClassInstance( // if shouldComponentUpdate returns false. instance.props = newProps; instance.state = newState; - instance.context = nextLegacyContext; + instance.context = nextContext; return shouldUpdate; } @@ -8675,7 +8789,7 @@ var warnForMissingKey = function(child) {}; }; } -var isArray$1 = Array.isArray; +var isArray = Array.isArray; function coerceRef(returnFiber, current$$1, element) { var mixedRef = element.ref; @@ -8712,7 +8826,7 @@ function coerceRef(returnFiber, current$$1, element) { invariant( ownerFiber.tag === ClassComponent || ownerFiber.tag === ClassComponentLazy, - "Stateless function components cannot have refs." + "Function components cannot have refs." ); inst = ownerFiber.stateNode; } @@ -8755,7 +8869,7 @@ function coerceRef(returnFiber, current$$1, element) { element._owner, "Element ref was specified as a string (%s) but no owner was set. This could happen for one of" + " the following reasons:\n" + - "1. You may be adding a ref to a functional component\n" + + "1. You may be adding a ref to a function component\n" + "2. You may be adding a ref to a component that was not created inside a component's render method\n" + "3. You have multiple copies of React loaded\n" + "See https://fb.me/react-refs-must-have-owner for more information.", @@ -9043,7 +9157,7 @@ function ChildReconciler(shouldTrackSideEffects) { } } - if (isArray$1(newChild) || getIteratorFn(newChild)) { + if (isArray(newChild) || getIteratorFn(newChild)) { var _created3 = createFiberFromFragment( newChild, returnFiber.mode, @@ -9123,7 +9237,7 @@ function ChildReconciler(shouldTrackSideEffects) { } } - if (isArray$1(newChild) || getIteratorFn(newChild)) { + if (isArray(newChild) || getIteratorFn(newChild)) { if (key !== null) { return null; } @@ -9205,7 +9319,7 @@ function ChildReconciler(shouldTrackSideEffects) { } } - if (isArray$1(newChild) || getIteratorFn(newChild)) { + if (isArray(newChild) || getIteratorFn(newChild)) { var _matchedFiber3 = existingChildren.get(newIdx) || null; return updateFragment( returnFiber, @@ -9820,7 +9934,7 @@ function ChildReconciler(shouldTrackSideEffects) { ); } - if (isArray$1(newChild)) { + if (isArray(newChild)) { return reconcileChildrenArray( returnFiber, currentFirstChild, @@ -9865,7 +9979,7 @@ function ChildReconciler(shouldTrackSideEffects) { // Intentionally fall through to the next case, which handles both // functions and classes // eslint-disable-next-lined no-fallthrough - case FunctionalComponent: { + case FunctionComponent: { var Component = returnFiber.type; invariant( false, @@ -10282,13 +10396,15 @@ function readLazyComponentType(thenable) { var ReactCurrentOwner$3 = ReactSharedInternals.ReactCurrentOwner; var didWarnAboutBadClass = void 0; -var didWarnAboutGetDerivedStateOnFunctionalComponent = void 0; -var didWarnAboutStatelessRefs = void 0; +var didWarnAboutContextTypeOnFunctionComponent = void 0; +var didWarnAboutGetDerivedStateOnFunctionComponent = void 0; +var didWarnAboutFunctionRefs = void 0; { didWarnAboutBadClass = {}; - didWarnAboutGetDerivedStateOnFunctionalComponent = {}; - didWarnAboutStatelessRefs = {}; + didWarnAboutContextTypeOnFunctionComponent = {}; + didWarnAboutGetDerivedStateOnFunctionComponent = {}; + didWarnAboutFunctionRefs = {}; } function reconcileChildren( @@ -10324,6 +10440,38 @@ function reconcileChildren( } } +function forceUnmountCurrentAndReconcile( + current$$1, + workInProgress, + nextChildren, + renderExpirationTime +) { + // This function is fork of reconcileChildren. It's used in cases where we + // want to reconcile without matching against the existing set. This has the + // effect of all current children being unmounted; even if the type and key + // are the same, the old child is unmounted and a new child is created. + // + // To do this, we're going to go through the reconcile algorithm twice. In + // the first pass, we schedule a deletion for all the current children by + // passing null. + workInProgress.child = reconcileChildFibers( + workInProgress, + current$$1.child, + null, + 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. + workInProgress.child = reconcileChildFibers( + workInProgress, + null, + nextChildren, + renderExpirationTime + ); +} + function updateForwardRef( current$$1, workInProgress, @@ -10365,6 +10513,56 @@ function updateForwardRef( return workInProgress.child; } +function updatePureComponent( + current$$1, + workInProgress, + Component, + nextProps, + updateExpirationTime, + renderExpirationTime +) { + var render = Component.render; + + if ( + current$$1 !== null && + (updateExpirationTime === NoWork || + updateExpirationTime > renderExpirationTime) + ) { + var prevProps = current$$1.memoizedProps; + // Default to shallow comparison + var compare = Component.compare; + compare = compare !== null ? compare : shallowEqual; + if (compare(prevProps, nextProps)) { + return bailoutOnAlreadyFinishedWork( + current$$1, + workInProgress, + renderExpirationTime + ); + } + } + + // The rest is a fork of updateFunctionComponent + var nextChildren = void 0; + prepareToReadContext(workInProgress, renderExpirationTime); + { + ReactCurrentOwner$3.current = workInProgress; + setCurrentPhase("render"); + nextChildren = render(nextProps); + setCurrentPhase(null); + } + + // React DevTools reads this flag. + workInProgress.effectTag |= PerformedWork; + reconcileChildren( + current$$1, + workInProgress, + nextChildren, + renderExpirationTime + ); + memoizeProps(workInProgress, nextProps); + return workInProgress.child; +} + function updateFragment(current$$1, workInProgress, renderExpirationTime) { var nextChildren = workInProgress.pendingProps; reconcileChildren( @@ -10416,7 +10614,7 @@ function markRef(current$$1, workInProgress) { } } -function updateFunctionalComponent( +function updateFunctionComponent( current$$1, workInProgress, Component, @@ -10544,8 +10742,7 @@ function finishClassComponent( var nextChildren = void 0; if ( didCaptureError && - (!enableGetDerivedStateFromCatch || - typeof Component.getDerivedStateFromCatch !== "function") + typeof Component.getDerivedStateFromError !== "function" ) { // If we captured an error, but getDerivedStateFrom catch is not defined, // unmount all the children. componentDidCatch will schedule an update to @@ -10575,20 +10772,25 @@ function finishClassComponent( // React DevTools reads this flag. workInProgress.effectTag |= PerformedWork; if (current$$1 !== null && didCaptureError) { - // If we're recovering from an error, reconcile twice: first to delete - // all the existing children. - reconcileChildren(current$$1, workInProgress, null, renderExpirationTime); - workInProgress.child = null; - // Now we can continue reconciling like normal. This has the effect of - // remounting all children regardless of whether their their - // identity matches. + // If we're recovering from an error, reconcile without reusing any of + // the existing children. Conceptually, the normal children and the children + // that are shown on error are two different sets, so we shouldn't reuse + // normal children even if their identities match. + forceUnmountCurrentAndReconcile( + current$$1, + workInProgress, + nextChildren, + renderExpirationTime + ); + } else { + reconcileChildren( + current$$1, + workInProgress, + nextChildren, + renderExpirationTime + ); } - reconcileChildren( - current$$1, - workInProgress, - nextChildren, - renderExpirationTime - ); + // Memoize props and state using the values we just used to render. // TODO: Restructure so we never read values from the instance. memoizeState(workInProgress, instance.state); @@ -10721,7 +10923,7 @@ function updateHostComponent(current$$1, workInProgress, renderExpirationTime) { // Check the host config to see if the children are offscreen/hidden. if ( renderExpirationTime !== Never && - workInProgress.mode & AsyncMode && + workInProgress.mode & ConcurrentMode && shouldDeprioritizeSubtree(type, nextProps) ) { // Schedule this fiber to re-render at offscreen priority. Then bailout. @@ -10770,6 +10972,7 @@ function mountIndeterminateComponent( current$$1, workInProgress, Component, + updateExpirationTime, renderExpirationTime ) { invariant( @@ -10790,37 +10993,53 @@ function mountIndeterminateComponent( Component )); var resolvedProps = resolveDefaultProps(Component, props); + var child = void 0; switch (resolvedTag) { - case FunctionalComponentLazy: { - return updateFunctionalComponent( + case FunctionComponentLazy: { + child = updateFunctionComponent( current$$1, workInProgress, Component, resolvedProps, renderExpirationTime ); + break; } case ClassComponentLazy: { - return updateClassComponent( + child = updateClassComponent( current$$1, workInProgress, Component, resolvedProps, renderExpirationTime ); + break; } case ForwardRefLazy: { - return updateForwardRef( + child = updateForwardRef( current$$1, workInProgress, Component, resolvedProps, renderExpirationTime ); + break; + } + case PureComponentLazy: { + child = updatePureComponent( + current$$1, + workInProgress, + Component, + resolvedProps, + updateExpirationTime, + renderExpirationTime + ); + break; } default: { - // This message intentionally doesn't metion ForwardRef because the - // fact that it's a separate type of work is an implementation detail. + // This message intentionally doesn't metion ForwardRef or PureComponent + // because the fact that it's a separate type of work is an + // implementation detail. invariant( false, "Element type is invalid. Received a promise that resolves to: %s. " + @@ -10829,6 +11048,8 @@ function mountIndeterminateComponent( ); } } + workInProgress.memoizedProps = props; + return child; } var unmaskedContext = getUnmaskedContext(workInProgress, Component, false); @@ -10911,14 +11132,14 @@ function mountIndeterminateComponent( renderExpirationTime ); } else { - // Proceed under the assumption that this is a functional component - workInProgress.tag = FunctionalComponent; + // Proceed under the assumption that this is a function component + workInProgress.tag = FunctionComponent; { if (Component) { !!Component.childContextTypes ? warningWithoutStack$1( false, - "%s(...): childContextTypes cannot be defined on a functional component.", + "%s(...): childContextTypes cannot be defined on a function component.", Component.displayName || Component.name || "Component" ) : void 0; @@ -10935,11 +11156,11 @@ function mountIndeterminateComponent( if (debugSource) { warningKey = debugSource.fileName + ":" + debugSource.lineNumber; } - if (!didWarnAboutStatelessRefs[warningKey]) { - didWarnAboutStatelessRefs[warningKey] = true; + if (!didWarnAboutFunctionRefs[warningKey]) { + didWarnAboutFunctionRefs[warningKey] = true; warning$1( false, - "Stateless function components cannot be given refs. " + + "Function components cannot be given refs. " + "Attempts to access this ref will fail.%s", info ); @@ -10949,15 +11170,29 @@ function mountIndeterminateComponent( if (typeof Component.getDerivedStateFromProps === "function") { var _componentName = getComponentName(Component) || "Unknown"; - if (!didWarnAboutGetDerivedStateOnFunctionalComponent[_componentName]) { + if (!didWarnAboutGetDerivedStateOnFunctionComponent[_componentName]) { warningWithoutStack$1( false, - "%s: Stateless functional components do not support getDerivedStateFromProps.", + "%s: Function components do not support getDerivedStateFromProps.", _componentName ); - didWarnAboutGetDerivedStateOnFunctionalComponent[ - _componentName - ] = true; + didWarnAboutGetDerivedStateOnFunctionComponent[_componentName] = true; + } + } + + if ( + typeof Component.contextType === "object" && + Component.contextType !== null + ) { + var _componentName2 = getComponentName(Component) || "Unknown"; + + if (!didWarnAboutContextTypeOnFunctionComponent[_componentName2]) { + warningWithoutStack$1( + false, + "%s: Function components do not support contextType.", + _componentName2 + ); + didWarnAboutContextTypeOnFunctionComponent[_componentName2] = true; } } } @@ -10985,13 +11220,6 @@ function updatePlaceholderComponent( // suspended during the last commit. Switch to the placholder. workInProgress.updateQueue = null; nextDidTimeout = true; - // If we're recovering from an error, reconcile twice: first to delete - // all the existing children. - reconcileChildren(current$$1, workInProgress, null, renderExpirationTime); - current$$1.child = null; - // Now we can continue reconciling like normal. This has the effect of - // remounting all children regardless of whether their their - // identity matches. } else { nextDidTimeout = !alreadyCaptured; } @@ -11018,14 +11246,31 @@ function updatePlaceholderComponent( nextChildren = nextDidTimeout ? nextProps.fallback : children; } + if ( + current$$1 !== null && + nextDidTimeout !== workInProgress.memoizedState + ) { + // We're about to switch from the placeholder children to the normal + // children, or vice versa. These are two different conceptual sets that + // happen to be stored in the same set. Call this special function to + // force the new set not to match with the current set. + // TODO: The proper way to model this is by storing each set separately. + forceUnmountCurrentAndReconcile( + current$$1, + workInProgress, + nextChildren, + renderExpirationTime + ); + } else { + reconcileChildren( + current$$1, + workInProgress, + nextChildren, + renderExpirationTime + ); + } workInProgress.memoizedProps = nextProps; workInProgress.memoizedState = nextDidTimeout; - reconcileChildren( - current$$1, - workInProgress, - nextChildren, - renderExpirationTime - ); return workInProgress.child; } else { return null; @@ -11238,59 +11483,65 @@ function memoizeState(workInProgress, nextState) { function beginWork(current$$1, workInProgress, renderExpirationTime) { var updateExpirationTime = workInProgress.expirationTime; - if ( - !hasContextChanged() && - (updateExpirationTime === NoWork || - updateExpirationTime > renderExpirationTime) - ) { - // This fiber does not have any pending work. Bailout without entering - // the begin phase. There's still some bookkeeping we that needs to be done - // in this optimized path, mostly pushing stuff onto the stack. - switch (workInProgress.tag) { - case HostRoot: - pushHostRootContext(workInProgress); - resetHydrationState(); - break; - case HostComponent: - pushHostContext(workInProgress); - break; - case ClassComponent: { - var Component = workInProgress.type; - if (isContextProvider(Component)) { - pushContextProvider(workInProgress); + + if (current$$1 !== null) { + var oldProps = current$$1.memoizedProps; + var newProps = workInProgress.pendingProps; + if ( + oldProps === newProps && + !hasContextChanged() && + (updateExpirationTime === NoWork || + updateExpirationTime > renderExpirationTime) + ) { + // This fiber does not have any pending work. Bailout without entering + // the begin phase. There's still some bookkeeping we that needs to be done + // in this optimized path, mostly pushing stuff onto the stack. + switch (workInProgress.tag) { + case HostRoot: + pushHostRootContext(workInProgress); + resetHydrationState(); + break; + case HostComponent: + pushHostContext(workInProgress); + break; + case ClassComponent: { + var Component = workInProgress.type; + if (isContextProvider(Component)) { + pushContextProvider(workInProgress); + } + break; } - break; - } - case ClassComponentLazy: { - var thenable = workInProgress.type; - var _Component = getResultFromResolvedThenable(thenable); - if (isContextProvider(_Component)) { - pushContextProvider(workInProgress); + case ClassComponentLazy: { + var thenable = workInProgress.type; + var _Component = getResultFromResolvedThenable(thenable); + if (isContextProvider(_Component)) { + pushContextProvider(workInProgress); + } + break; } - break; - } - case HostPortal: - pushHostContainer( - workInProgress, - workInProgress.stateNode.containerInfo - ); - break; - case ContextProvider: { - var newValue = workInProgress.memoizedProps.value; - pushProvider(workInProgress, newValue); - break; - } - case Profiler: - if (enableProfilerTimer) { - workInProgress.effectTag |= Update; + case HostPortal: + pushHostContainer( + workInProgress, + workInProgress.stateNode.containerInfo + ); + break; + case ContextProvider: { + var newValue = workInProgress.memoizedProps.value; + pushProvider(workInProgress, newValue); + break; } - break; + case Profiler: + if (enableProfilerTimer) { + workInProgress.effectTag |= Update; + } + break; + } + return bailoutOnAlreadyFinishedWork( + current$$1, + workInProgress, + renderExpirationTime + ); } - return bailoutOnAlreadyFinishedWork( - current$$1, - workInProgress, - renderExpirationTime - ); } // Before entering the begin phase, clear the expiration time. @@ -11298,63 +11549,64 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { switch (workInProgress.tag) { case IndeterminateComponent: { - var _Component3 = workInProgress.type; + var _Component2 = workInProgress.type; return mountIndeterminateComponent( current$$1, workInProgress, - _Component3, + _Component2, + updateExpirationTime, renderExpirationTime ); } - case FunctionalComponent: { - var _Component4 = workInProgress.type; - var _unresolvedProps = workInProgress.pendingProps; - return updateFunctionalComponent( + case FunctionComponent: { + var _Component3 = workInProgress.type; + var unresolvedProps = workInProgress.pendingProps; + return updateFunctionComponent( current$$1, workInProgress, - _Component4, - _unresolvedProps, + _Component3, + unresolvedProps, renderExpirationTime ); } - case FunctionalComponentLazy: { - var _thenable2 = workInProgress.type; - var _Component5 = getResultFromResolvedThenable(_thenable2); - var _unresolvedProps2 = workInProgress.pendingProps; - var _child = updateFunctionalComponent( + case FunctionComponentLazy: { + var _thenable = workInProgress.type; + var _Component4 = getResultFromResolvedThenable(_thenable); + var _unresolvedProps = workInProgress.pendingProps; + var child = updateFunctionComponent( current$$1, workInProgress, - _Component5, - resolveDefaultProps(_Component5, _unresolvedProps2), + _Component4, + resolveDefaultProps(_Component4, _unresolvedProps), renderExpirationTime ); - workInProgress.memoizedProps = _unresolvedProps2; - return _child; + workInProgress.memoizedProps = _unresolvedProps; + return child; } case ClassComponent: { - var _Component6 = workInProgress.type; - var _unresolvedProps3 = workInProgress.pendingProps; + var _Component5 = workInProgress.type; + var _unresolvedProps2 = workInProgress.pendingProps; return updateClassComponent( current$$1, workInProgress, - _Component6, - _unresolvedProps3, + _Component5, + _unresolvedProps2, renderExpirationTime ); } case ClassComponentLazy: { - var _thenable3 = workInProgress.type; - var _Component7 = getResultFromResolvedThenable(_thenable3); - var _unresolvedProps4 = workInProgress.pendingProps; - var _child2 = updateClassComponent( + var _thenable2 = workInProgress.type; + var _Component6 = getResultFromResolvedThenable(_thenable2); + var _unresolvedProps3 = workInProgress.pendingProps; + var _child = updateClassComponent( current$$1, workInProgress, - _Component7, - resolveDefaultProps(_Component7, _unresolvedProps4), + _Component6, + resolveDefaultProps(_Component6, _unresolvedProps3), renderExpirationTime ); - workInProgress.memoizedProps = _unresolvedProps4; - return _child2; + workInProgress.memoizedProps = _unresolvedProps3; + return _child; } case HostRoot: return updateHostRoot(current$$1, workInProgress, renderExpirationTime); @@ -11388,19 +11640,20 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { renderExpirationTime ); } - case ForwardRefLazy: - var _thenable = workInProgress.type; - var _Component2 = getResultFromResolvedThenable(_thenable); - var unresolvedProps = workInProgress.pendingProps; - var child = updateForwardRef( + case ForwardRefLazy: { + var _thenable3 = workInProgress.type; + var _Component7 = getResultFromResolvedThenable(_thenable3); + var _unresolvedProps4 = workInProgress.pendingProps; + var _child2 = updateForwardRef( current$$1, workInProgress, - _Component2, - resolveDefaultProps(_Component2, unresolvedProps), + _Component7, + resolveDefaultProps(_Component7, _unresolvedProps4), renderExpirationTime ); - workInProgress.memoizedProps = unresolvedProps; - return child; + workInProgress.memoizedProps = _unresolvedProps4; + return _child2; + } case Fragment: return updateFragment(current$$1, workInProgress, renderExpirationTime); case Mode: @@ -11419,6 +11672,32 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { workInProgress, renderExpirationTime ); + case PureComponent: { + var _type = workInProgress.type; + return updatePureComponent( + current$$1, + workInProgress, + _type, + workInProgress.pendingProps, + updateExpirationTime, + renderExpirationTime + ); + } + case PureComponentLazy: { + var _thenable4 = workInProgress.type; + var _Component8 = getResultFromResolvedThenable(_thenable4); + var _unresolvedProps5 = workInProgress.pendingProps; + var _child3 = updatePureComponent( + current$$1, + workInProgress, + _Component8, + resolveDefaultProps(_Component8, _unresolvedProps5), + updateExpirationTime, + renderExpirationTime + ); + workInProgress.memoizedProps = _unresolvedProps5; + return _child3; + } default: invariant( false, @@ -11684,8 +11963,8 @@ function completeWork(current, workInProgress, renderExpirationTime) { var newProps = workInProgress.pendingProps; switch (workInProgress.tag) { - case FunctionalComponent: - case FunctionalComponentLazy: + case FunctionComponent: + case FunctionComponentLazy: break; case ClassComponent: { var Component = workInProgress.type; @@ -11857,6 +12136,9 @@ function completeWork(current, workInProgress, renderExpirationTime) { break; case ContextConsumer: break; + case PureComponent: + case PureComponentLazy: + break; // Error cases case IndeterminateComponent: invariant( @@ -12220,7 +12502,7 @@ function commitLifeCycles( if (enableProfilerTimer) { var onRender = finishedWork.memoizedProps.onRender; - if (enableSchedulerTracking) { + if (enableSchedulerTracing) { onRender( finishedWork.memoizedProps.id, current$$1 === null ? "mount" : "update", @@ -12789,28 +13071,22 @@ function createRootErrorUpdate(fiber, errorInfo, expirationTime) { function createClassErrorUpdate(fiber, errorInfo, expirationTime) { var update = createUpdate(expirationTime); update.tag = CaptureUpdate; - var getDerivedStateFromCatch = fiber.type.getDerivedStateFromCatch; - if ( - enableGetDerivedStateFromCatch && - typeof getDerivedStateFromCatch === "function" - ) { + var getDerivedStateFromError = fiber.type.getDerivedStateFromError; + if (typeof getDerivedStateFromError === "function") { var error = errorInfo.value; update.payload = function() { - return getDerivedStateFromCatch(error); + return getDerivedStateFromError(error); }; } var inst = fiber.stateNode; if (inst !== null && typeof inst.componentDidCatch === "function") { update.callback = function callback() { - if ( - !enableGetDerivedStateFromCatch || - getDerivedStateFromCatch !== "function" - ) { + if (typeof getDerivedStateFromError !== "function") { // To preserve the preexisting retry behavior of error boundaries, // we keep track of which ones already failed during this batch. // This gets reset before we yield back to the browser. - // TODO: Warn in strict mode if getDerivedStateFromCatch is + // TODO: Warn in strict mode if getDerivedStateFromError is // not defined. markLegacyErrorBoundaryAsFailed(this); } @@ -12820,6 +13096,21 @@ function createClassErrorUpdate(fiber, errorInfo, expirationTime) { this.componentDidCatch(error, { componentStack: stack !== null ? stack : "" }); + { + if (typeof getDerivedStateFromError !== "function") { + // If componentDidCatch is the only error boundary method defined, + // then it needs to call setState to recover from errors. + // If no state update is scheduled then the boundary will swallow the error. + !(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; + } + } }; } return update; @@ -12896,10 +13187,10 @@ function throwException( if (!didTimeout) { // Found the nearest boundary. - // If the boundary is not in async mode, we should not suspend, and + // If the boundary is not in concurrent mode, we should not suspend, and // likewise, when the promise resolves, we should ping synchronously. var pingTime = - (_workInProgress.mode & AsyncMode) === NoEffect + (_workInProgress.mode & ConcurrentMode) === NoEffect ? Sync : renderExpirationTime; @@ -12910,6 +13201,9 @@ function throwException( _workInProgress, pingTime ); + if (enableSchedulerTracing) { + onResolveOrReject = tracing.unstable_wrap(onResolveOrReject); + } thenable.then(onResolveOrReject, onResolveOrReject); // If the boundary is outside of strict mode, we should *not* suspend @@ -12933,9 +13227,9 @@ function throwException( ); sourceFiber.effectTag &= ~Incomplete; if (sourceFiber.tag === IndeterminateComponent) { - // Let's just assume it's a functional component. This fiber will + // Let's just assume it's a function component. This fiber will // be unmounted in the immediate next commit, anyway. - sourceFiber.tag = FunctionalComponent; + sourceFiber.tag = FunctionComponent; } if ( @@ -12948,11 +13242,11 @@ function throwException( sourceFiber.effectTag &= ~LifecycleEffectMask; if (sourceFiber.alternate === null) { // We're about to mount a class component that doesn't have an - // instance. Turn this into a dummy functional component instead, + // instance. Turn this into a dummy function component instead, // to prevent type errors. This is a bit weird but it's an edge // case and we're about to synchronously delete this // component, anyway. - sourceFiber.tag = FunctionalComponent; + sourceFiber.tag = FunctionComponent; sourceFiber.type = NoopComponent; } } @@ -13042,8 +13336,7 @@ function throwException( var instance = workInProgress.stateNode; if ( (workInProgress.effectTag & DidCapture) === NoEffect && - ((typeof ctor.getDerivedStateFromCatch === "function" && - enableGetDerivedStateFromCatch) || + (typeof ctor.getDerivedStateFromError === "function" || (instance !== null && typeof instance.componentDidCatch === "function" && !isAlreadyFailedLegacyErrorBoundary(instance))) @@ -13176,14 +13469,14 @@ var didWarnSetStateChildContext = void 0; var warnAboutUpdateOnUnmounted = void 0; var warnAboutInvalidUpdates = void 0; -if (enableSchedulerTracking) { +if (enableSchedulerTracing) { // Provide explicit error message when production+profiling bundle of e.g. react-dom - // is used with production (non-profiling) bundle of schedule/tracking + // is used with production (non-profiling) bundle of schedule/tracing invariant( - tracking.__interactionsRef != null && - tracking.__interactionsRef.current != null, + tracing.__interactionsRef != null && + tracing.__interactionsRef.current != null, "It is not supported to run the profiling version of a renderer (for example, `react-dom/profiling`) " + - "without also replacing the `schedule/tracking` module with `schedule/tracking-profiling`. " + + "without also replacing the `schedule/tracing` module with `schedule/tracing-profiling`. " + "Your bundler might have a setting for aliasing both modules. " + "Learn more at http://fb.me/react-profiling" ); @@ -13264,10 +13557,6 @@ var legacyErrorBoundariesThatAlreadyFailed = null; // Used for performance tracking. var interruptedBy = null; -// Do not decrement interaction counts in the event of suspense timeouts. -// This would lead to prematurely calling the interaction-complete hook. -var suspenseDidTimeout = false; - var stashedWorkInProgressProperties = void 0; var replayUnitOfWork = void 0; var isReplayingFailedUnitOfWork = void 0; @@ -13477,14 +13766,11 @@ function commitBeforeMutationLifecycles() { function commitAllLifeCycles(finishedRoot, committedExpirationTime) { { ReactStrictModeWarnings.flushPendingUnsafeLifecycleWarnings(); + ReactStrictModeWarnings.flushLegacyContextWarning(); if (warnAboutDeprecatedLifecycles) { ReactStrictModeWarnings.flushPendingDeprecationWarnings(); } - - if (warnAboutLegacyContextAPI) { - ReactStrictModeWarnings.flushLegacyContextWarning(); - } } while (nextEffect !== null) { var effectTag = nextEffect.effectTag; @@ -13565,33 +13851,11 @@ function commitRoot(root, finishedWork) { markCommittedPriorityLevels(root, earliestRemainingTimeBeforeCommit); var prevInteractions = null; - var committedInteractions = enableSchedulerTracking ? [] : null; - if (enableSchedulerTracking) { + if (enableSchedulerTracing) { // Restore any pending interactions at this point, // So that cascading work triggered during the render phase will be accounted for. - prevInteractions = tracking.__interactionsRef.current; - tracking.__interactionsRef.current = root.memoizedInteractions; - - // We are potentially finished with the current batch of interactions. - // So we should clear them out of the pending interaction map. - // We do this at the start of commit in case cascading work is scheduled by commit phase lifecycles. - // In that event, interaction data may be added back into the pending map for a future commit. - // We also store the interactions we are about to commit so that we can notify subscribers after we're done. - // These are stored as an Array rather than a Set, - // Because the same interaction may be pending for multiple expiration times, - // In which case it's important that we decrement the count the right number of times after finishing. - root.pendingInteractionMap.forEach(function( - scheduledInteractions, - scheduledExpirationTime - ) { - if (scheduledExpirationTime <= committedExpirationTime) { - committedInteractions.push.apply( - committedInteractions, - Array.from(scheduledInteractions) - ); - root.pendingInteractionMap.delete(scheduledExpirationTime); - } - }); + prevInteractions = tracing.__interactionsRef.current; + tracing.__interactionsRef.current = root.memoizedInteractions; } // Reset this to null before calling lifecycles @@ -13747,13 +14011,13 @@ function commitRoot(root, finishedWork) { } onCommit(root, earliestRemainingTimeAfterCommit); - if (enableSchedulerTracking) { - tracking.__interactionsRef.current = prevInteractions; + if (enableSchedulerTracing) { + tracing.__interactionsRef.current = prevInteractions; var subscriber = void 0; try { - subscriber = tracking.__subscriberRef.current; + subscriber = tracing.__subscriberRef.current; if (subscriber !== null && root.memoizedInteractions.size > 0) { var threadID = computeThreadID( committedExpirationTime, @@ -13769,28 +14033,41 @@ function commitRoot(root, finishedWork) { unhandledError = error; } } finally { - // Don't update interaction counts if we're frozen due to suspense. - // In this case, we can skip the completed-work check entirely. - if (!suspenseDidTimeout) { - // Now that we're done, check the completed batch of interactions. - // If no more work is outstanding for a given interaction, - // We need to notify the subscribers that it's finished. - committedInteractions.forEach(function(interaction) { - interaction.__count--; - if (subscriber !== null && interaction.__count === 0) { - try { - subscriber.onInteractionScheduledWorkCompleted(interaction); - } catch (error) { - // It's not safe for commitRoot() to throw. - // Store the error for now and we'll re-throw in finishRendering(). - if (!hasUnhandledError) { - hasUnhandledError = true; - unhandledError = error; + // Clear completed interactions from the pending Map. + // Unless the render was suspended or cascading work was scheduled, + // In which case– leave pending interactions until the subsequent render. + var pendingInteractionMap = root.pendingInteractionMap; + pendingInteractionMap.forEach(function( + scheduledInteractions, + scheduledExpirationTime + ) { + // Only decrement the pending interaction count if we're done. + // If there's still work at the current priority, + // That indicates that we are waiting for suspense data. + if ( + earliestRemainingTimeAfterCommit === NoWork || + scheduledExpirationTime < earliestRemainingTimeAfterCommit + ) { + pendingInteractionMap.delete(scheduledExpirationTime); + + scheduledInteractions.forEach(function(interaction) { + interaction.__count--; + + if (subscriber !== null && interaction.__count === 0) { + try { + subscriber.onInteractionScheduledWorkCompleted(interaction); + } catch (error) { + // It's not safe for commitRoot() to throw. + // Store the error for now and we'll re-throw in finishRendering(). + if (!hasUnhandledError) { + hasUnhandledError = true; + unhandledError = error; + } } } - } - }); - } + }); + } + }); } } } @@ -13915,23 +14192,12 @@ function completeUnitOfWork(workInProgress) { nextRenderExpirationTime ); } - var next = nextUnitOfWork; stopWorkTimer(workInProgress); resetChildExpirationTime(workInProgress, nextRenderExpirationTime); { resetCurrentFiber(); } - if (next !== null) { - stopWorkTimer(workInProgress); - if (true && ReactFiberInstrumentation_1.debugTool) { - ReactFiberInstrumentation_1.debugTool.onCompleteWork(workInProgress); - } - // If completing this work spawned new work, do that next. We'll come - // back here again. - return next; - } - if ( returnFiber !== null && // Do not append effects to parents if a sibling failed to complete @@ -13993,7 +14259,7 @@ function completeUnitOfWork(workInProgress) { // This fiber did not complete because something threw. Pop values off // the stack without entering the complete phase. If this is a boundary, // capture values if possible. - var _next = unwindWork(workInProgress, nextRenderExpirationTime); + var next = unwindWork(workInProgress, nextRenderExpirationTime); // Because this fiber did not complete, don't reset its expiration time. if (workInProgress.effectTag & DidCapture) { // Restarting an error boundary @@ -14006,7 +14272,7 @@ function completeUnitOfWork(workInProgress) { resetCurrentFiber(); } - if (_next !== null) { + if (next !== null) { stopWorkTimer(workInProgress); if (true && ReactFiberInstrumentation_1.debugTool) { ReactFiberInstrumentation_1.debugTool.onCompleteWork(workInProgress); @@ -14014,14 +14280,14 @@ function completeUnitOfWork(workInProgress) { if (enableProfilerTimer) { // Include the time spent working on failed children before continuing. - if (_next.mode & ProfileMode) { - var actualDuration = _next.actualDuration; - var child = _next.child; + if (next.mode & ProfileMode) { + var actualDuration = next.actualDuration; + var child = next.child; while (child !== null) { actualDuration += child.actualDuration; child = child.sibling; } - _next.actualDuration = actualDuration; + next.actualDuration = actualDuration; } } @@ -14029,8 +14295,8 @@ function completeUnitOfWork(workInProgress) { // back here again. // Since we're restarting, remove anything that is not a host effect // from the effect tag. - _next.effectTag &= HostEffectMask; - return _next; + next.effectTag &= HostEffectMask; + return next; } if (returnFiber !== null) { @@ -14147,14 +14413,6 @@ function renderRoot(root, isYieldy, isExpired) { var expirationTime = root.nextExpirationTimeToWorkOn; - var prevInteractions = null; - if (enableSchedulerTracking) { - // We're about to start new tracked work. - // Restore pending interactions so cascading work triggered during the render phase will be accounted for. - prevInteractions = tracking.__interactionsRef.current; - tracking.__interactionsRef.current = root.memoizedInteractions; - } - // Check if we're starting from a fresh stack, or if we're resuming from // previously yielded work. if ( @@ -14173,7 +14431,7 @@ function renderRoot(root, isYieldy, isExpired) { ); root.pendingCommitExpirationTime = NoWork; - if (enableSchedulerTracking) { + if (enableSchedulerTracing) { // Determine which interactions this batch of work currently includes, // So that we can accurately attribute time spent working on it, var interactions = new Set(); @@ -14195,7 +14453,7 @@ function renderRoot(root, isYieldy, isExpired) { root.memoizedInteractions = interactions; if (interactions.size > 0) { - var subscriber = tracking.__subscriberRef.current; + var subscriber = tracing.__subscriberRef.current; if (subscriber !== null) { var threadID = computeThreadID( expirationTime, @@ -14204,7 +14462,7 @@ function renderRoot(root, isYieldy, isExpired) { try { subscriber.onWorkStarted(interactions, threadID); } catch (error) { - // Work thrown by an interaction tracking subscriber should be rethrown, + // Work thrown by an interaction tracing subscriber should be rethrown, // But only once it's safe (to avoid leaveing the scheduler in an invalid state). // Store the error for now and we'll re-throw in finishRendering(). if (!hasUnhandledError) { @@ -14217,6 +14475,14 @@ function renderRoot(root, isYieldy, isExpired) { } } + var prevInteractions = null; + if (enableSchedulerTracing) { + // We're about to start new traced work. + // Restore pending interactions so cascading work triggered during the render phase will be accounted for. + prevInteractions = tracing.__interactionsRef.current; + tracing.__interactionsRef.current = root.memoizedInteractions; + } + var didFatal = false; startWorkLoopTimer(nextUnitOfWork); @@ -14278,9 +14544,9 @@ function renderRoot(root, isYieldy, isExpired) { break; } while (true); - if (enableSchedulerTracking) { - // Tracked work is done for now; restore the previous interactions. - tracking.__interactionsRef.current = prevInteractions; + if (enableSchedulerTracing) { + // Traced work is done for now; restore the previous interactions. + tracing.__interactionsRef.current = prevInteractions; } // We're done performing work. Time to clean up. @@ -14430,7 +14696,7 @@ function dispatch(sourceFiber, value, expirationTime) { var ctor = fiber.type; var instance = fiber.stateNode; if ( - typeof ctor.getDerivedStateFromCatch === "function" || + typeof ctor.getDerivedStateFromError === "function" || (typeof instance.componentDidCatch === "function" && !isAlreadyFailedLegacyErrorBoundary(instance)) ) { @@ -14494,7 +14760,7 @@ function computeExpirationForFiber(currentTime, fiber) { } else { // No explicit expiration context was set, and we're not currently // performing work. Calculate a new expiration time. - if (fiber.mode & AsyncMode) { + if (fiber.mode & ConcurrentMode) { if (isBatchingInteractiveUpdates) { // This is an interactive update expirationTime = computeInteractiveExpiration(currentTime); @@ -14516,10 +14782,7 @@ function computeExpirationForFiber(currentTime, fiber) { // This is an interactive update. Keep track of the lowest pending // interactive expiration time. This allows us to synchronously flush // all interactive updates when needed. - if ( - lowestPriorityPendingInteractiveExpirationTime === NoWork || - expirationTime > lowestPriorityPendingInteractiveExpirationTime - ) { + if (expirationTime > lowestPriorityPendingInteractiveExpirationTime) { lowestPriorityPendingInteractiveExpirationTime = expirationTime; } } @@ -14547,6 +14810,7 @@ function retrySuspendedRoot(root, fiber, suspendedTime) { if (isPriorityLevelSuspended(root, suspendedTime)) { // Ping at the original level retryTime = suspendedTime; + markPingedPriorityLevel(root, retryTime); } else { // Placeholder already timed out. Compute a new expiration time @@ -14555,26 +14819,39 @@ function retrySuspendedRoot(root, fiber, suspendedTime) { markPendingPriorityLevel(root, retryTime); } + // TODO: If the placeholder fiber has already rendered the primary children + // without suspending (that is, all of the promises have already resolved), + // we should not trigger another update here. One case this happens is when + // we are in sync mode and a single promise is thrown both on initial render + // and on update; we attach two .then(retrySuspendedRoot) callbacks and each + // one performs Sync work, rerendering the Placeholder. + + if ((fiber.mode & ConcurrentMode) !== NoContext) { + if (root === nextRoot && nextRenderExpirationTime === suspendedTime) { + // Received a ping at the same priority level at which we're currently + // rendering. Restart from the root. + nextRoot = null; + } + } + scheduleWorkToRoot(fiber, retryTime); var rootExpirationTime = root.expirationTime; if (rootExpirationTime !== NoWork) { - if (enableSchedulerTracking) { - // Restore previous interactions so that new work is associated with them. - var prevInteractions = tracking.__interactionsRef.current; - tracking.__interactionsRef.current = root.memoizedInteractions; - // Because suspense timeouts do not decrement the interaction count, - // Continued suspense work should also not increment the count. - storeInteractionsForExpirationTime(root, rootExpirationTime, false); - requestWork(root, rootExpirationTime); - tracking.__interactionsRef.current = prevInteractions; - } else { - requestWork(root, rootExpirationTime); - } + requestWork(root, rootExpirationTime); } } } function scheduleWorkToRoot(fiber, expirationTime) { + recordScheduleUpdate(); + + { + if (fiber.tag === ClassComponent || fiber.tag === ClassComponentLazy) { + var instance = fiber.stateNode; + warnAboutInvalidUpdates(instance); + } + } + // Update the source fiber's expiration time if ( fiber.expirationTime === NoWork || @@ -14592,103 +14869,92 @@ function scheduleWorkToRoot(fiber, expirationTime) { } // Walk the parent path to the root and update the child expiration time. var node = fiber.return; + var root = null; if (node === null && fiber.tag === HostRoot) { - return fiber.stateNode; - } - while (node !== null) { - alternate = node.alternate; - if ( - node.childExpirationTime === NoWork || - node.childExpirationTime > expirationTime - ) { - node.childExpirationTime = expirationTime; + root = fiber.stateNode; + } else { + while (node !== null) { + alternate = node.alternate; if ( + node.childExpirationTime === NoWork || + node.childExpirationTime > expirationTime + ) { + node.childExpirationTime = expirationTime; + if ( + alternate !== null && + (alternate.childExpirationTime === NoWork || + alternate.childExpirationTime > expirationTime) + ) { + alternate.childExpirationTime = expirationTime; + } + } else if ( alternate !== null && (alternate.childExpirationTime === NoWork || alternate.childExpirationTime > expirationTime) ) { alternate.childExpirationTime = expirationTime; } - } else if ( - alternate !== null && - (alternate.childExpirationTime === NoWork || - alternate.childExpirationTime > expirationTime) - ) { - alternate.childExpirationTime = expirationTime; - } - if (node.return === null && node.tag === HostRoot) { - return node.stateNode; + if (node.return === null && node.tag === HostRoot) { + root = node.stateNode; + break; + } + node = node.return; } - node = node.return; } - return null; -} -function storeInteractionsForExpirationTime( - root, - expirationTime, - updateInteractionCounts -) { - if (!enableSchedulerTracking) { - return; + if (root === null) { + if ( + true && + (fiber.tag === ClassComponent || fiber.tag === ClassComponentLazy) + ) { + warnAboutUpdateOnUnmounted(fiber); + } + return null; } - var interactions = tracking.__interactionsRef.current; - if (interactions.size > 0) { - var pendingInteractions = root.pendingInteractionMap.get(expirationTime); - if (pendingInteractions != null) { - interactions.forEach(function(interaction) { - if (updateInteractionCounts && !pendingInteractions.has(interaction)) { - // Update the pending async work count for previously unscheduled interaction. - interaction.__count++; - } + if (enableSchedulerTracing) { + var interactions = tracing.__interactionsRef.current; + if (interactions.size > 0) { + var pendingInteractionMap = root.pendingInteractionMap; + var pendingInteractions = pendingInteractionMap.get(expirationTime); + if (pendingInteractions != null) { + interactions.forEach(function(interaction) { + if (!pendingInteractions.has(interaction)) { + // Update the pending async work count for previously unscheduled interaction. + interaction.__count++; + } - pendingInteractions.add(interaction); - }); - } else { - root.pendingInteractionMap.set(expirationTime, new Set(interactions)); + pendingInteractions.add(interaction); + }); + } else { + pendingInteractionMap.set(expirationTime, new Set(interactions)); - // Update the pending async work count for the current interactions. - if (updateInteractionCounts) { + // Update the pending async work count for the current interactions. interactions.forEach(function(interaction) { interaction.__count++; }); } - } - var subscriber = tracking.__subscriberRef.current; - if (subscriber !== null) { - var threadID = computeThreadID(expirationTime, root.interactionThreadID); - subscriber.onWorkScheduled(interactions, threadID); + var subscriber = tracing.__subscriberRef.current; + if (subscriber !== null) { + var threadID = computeThreadID( + expirationTime, + root.interactionThreadID + ); + subscriber.onWorkScheduled(interactions, threadID); + } } } + + return root; } function scheduleWork(fiber, expirationTime) { - recordScheduleUpdate(); - - { - if (fiber.tag === ClassComponent || fiber.tag === ClassComponentLazy) { - var instance = fiber.stateNode; - warnAboutInvalidUpdates(instance); - } - } - var root = scheduleWorkToRoot(fiber, expirationTime); if (root === null) { - if ( - true && - (fiber.tag === ClassComponent || fiber.tag === ClassComponentLazy) - ) { - warnAboutUpdateOnUnmounted(fiber); - } return; } - if (enableSchedulerTracking) { - storeInteractionsForExpirationTime(root, expirationTime, true); - } - if ( !isWorking && nextRenderExpirationTime !== NoWork && @@ -14836,16 +15102,7 @@ function onTimeout(root, finishedWork, suspendedExpirationTime) { // because we're at the top of a timer event. recomputeCurrentRendererTime(); currentSchedulerTime = currentRendererTime; - - if (enableSchedulerTracking) { - // Don't update pending interaction counts for suspense timeouts, - // Because we know we still need to do more work in this case. - suspenseDidTimeout = true; - flushRoot(root, suspendedExpirationTime); - suspenseDidTimeout = false; - } else { - flushRoot(root, suspendedExpirationTime); - } + flushRoot(root, suspendedExpirationTime); } } @@ -15482,8 +15739,8 @@ function findHostInstance$1(component) { return hostFiber.stateNode; } -function createContainer(containerInfo, isAsync, hydrate) { - return createFiberRoot(containerInfo, isAsync, hydrate); +function createContainer(containerInfo, isConcurrent, hydrate) { + return createFiberRoot(containerInfo, isConcurrent, hydrate); } function updateContainer(element, container, parentComponent, callback) { @@ -15559,7 +15816,7 @@ function createPortal( // TODO: this is special because it gets imported during build. -var ReactVersion = "16.5.0"; +var ReactVersion = "16.5.2"; // Modules provided by RN: var NativeMethodsMixin = function(findNodeHandle, findHostInstance) { diff --git a/Libraries/Renderer/oss/ReactNativeRenderer-prod.js b/Libraries/Renderer/oss/ReactNativeRenderer-prod.js index cc861113ff7b7d..d0c3a268e3d018 100644 --- a/Libraries/Renderer/oss/ReactNativeRenderer-prod.js +++ b/Libraries/Renderer/oss/ReactNativeRenderer-prod.js @@ -1142,9 +1142,12 @@ var ReactSharedInternals = REACT_PROFILER_TYPE = hasSymbol ? Symbol.for("react.profiler") : 60114, REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for("react.provider") : 60109, REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for("react.context") : 60110, - REACT_ASYNC_MODE_TYPE = hasSymbol ? Symbol.for("react.async_mode") : 60111, + REACT_CONCURRENT_MODE_TYPE = hasSymbol + ? Symbol.for("react.concurrent_mode") + : 60111, REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for("react.forward_ref") : 60112, REACT_PLACEHOLDER_TYPE = hasSymbol ? Symbol.for("react.placeholder") : 60113, + REACT_PURE_TYPE = hasSymbol ? Symbol.for("react.pure") : 60115, MAYBE_ITERATOR_SYMBOL = "function" === typeof Symbol && Symbol.iterator; function getIteratorFn(maybeIterable) { if (null === maybeIterable || "object" !== typeof maybeIterable) return null; @@ -1158,8 +1161,8 @@ function getComponentName(type) { if ("function" === typeof type) return type.displayName || type.name || null; if ("string" === typeof type) return type; switch (type) { - case REACT_ASYNC_MODE_TYPE: - return "AsyncMode"; + case REACT_CONCURRENT_MODE_TYPE: + return "ConcurrentMode"; case REACT_FRAGMENT_TYPE: return "Fragment"; case REACT_PORTAL_TYPE: @@ -1178,10 +1181,11 @@ function getComponentName(type) { case REACT_PROVIDER_TYPE: return "Context.Provider"; case REACT_FORWARD_REF_TYPE: + var renderFn = type.render; + renderFn = renderFn.displayName || renderFn.name || ""; return ( - (type = type.render), - (type = type.displayName || type.name || ""), - "" !== type ? "ForwardRef(" + type + ")" : "ForwardRef" + type.displayName || + ("" !== renderFn ? "ForwardRef(" + renderFn + ")" : "ForwardRef") ); } if ( @@ -1813,7 +1817,17 @@ function shouldConstruct(Component) { Component = Component.prototype; return !(!Component || !Component.isReactComponent); } -function createWorkInProgress(current, pendingProps, expirationTime) { +function resolveLazyComponentTag(fiber, Component) { + if ("function" === typeof Component) + return shouldConstruct(Component) ? 3 : 1; + if (void 0 !== Component && null !== Component) { + fiber = Component.$$typeof; + if (fiber === REACT_FORWARD_REF_TYPE) return 14; + if (fiber === REACT_PURE_TYPE) return 18; + } + return 4; +} +function createWorkInProgress(current, pendingProps) { var workInProgress = current.alternate; null === workInProgress ? ((workInProgress = new FiberNode( @@ -1832,10 +1846,7 @@ function createWorkInProgress(current, pendingProps, expirationTime) { (workInProgress.firstEffect = null), (workInProgress.lastEffect = null)); workInProgress.childExpirationTime = current.childExpirationTime; - workInProgress.expirationTime = - pendingProps !== current.pendingProps - ? expirationTime - : current.expirationTime; + workInProgress.expirationTime = current.expirationTime; workInProgress.child = current.child; workInProgress.memoizedProps = current.memoizedProps; workInProgress.memoizedState = current.memoizedState; @@ -1862,7 +1873,7 @@ function createFiberFromElement(element, mode, expirationTime) { expirationTime, key ); - case REACT_ASYNC_MODE_TYPE: + case REACT_CONCURRENT_MODE_TYPE: fiberTag = 10; mode |= 3; break; @@ -1892,6 +1903,9 @@ function createFiberFromElement(element, mode, expirationTime) { case REACT_FORWARD_REF_TYPE: fiberTag = 13; break a; + case REACT_PURE_TYPE: + fiberTag = 17; + break a; default: if ("function" === typeof type.then) { fiberTag = 4; @@ -2377,15 +2391,11 @@ function checkShouldComponentUpdate( newProps, oldState, newState, - nextLegacyContext + nextContext ) { workInProgress = workInProgress.stateNode; return "function" === typeof workInProgress.shouldComponentUpdate - ? workInProgress.shouldComponentUpdate( - newProps, - newState, - nextLegacyContext - ) + ? workInProgress.shouldComponentUpdate(newProps, newState, nextContext) : ctor.prototype && ctor.prototype.isPureReactComponent ? !shallowEqual(oldProps, newProps) || !shallowEqual(oldState, newState) : !0; @@ -2394,13 +2404,13 @@ function callComponentWillReceiveProps( workInProgress, instance, newProps, - nextLegacyContext + nextContext ) { workInProgress = instance.state; "function" === typeof instance.componentWillReceiveProps && - instance.componentWillReceiveProps(newProps, nextLegacyContext); + instance.componentWillReceiveProps(newProps, nextContext); "function" === typeof instance.UNSAFE_componentWillReceiveProps && - instance.UNSAFE_componentWillReceiveProps(newProps, nextLegacyContext); + instance.UNSAFE_componentWillReceiveProps(newProps, nextContext); instance.state !== workInProgress && classComponentUpdater.enqueueReplaceState(instance, instance.state, null); } @@ -2410,32 +2420,30 @@ function mountClassInstance( newProps, renderExpirationTime ) { - var instance = workInProgress.stateNode, - unmaskedContext = isContextProvider(ctor) - ? previousContext - : contextStackCursor.current; + var instance = workInProgress.stateNode; instance.props = newProps; instance.state = workInProgress.memoizedState; instance.refs = emptyRefsObject; - instance.context = getMaskedContext(workInProgress, unmaskedContext); - unmaskedContext = workInProgress.updateQueue; - null !== unmaskedContext && + var contextType = ctor.contextType; + "object" === typeof contextType && null !== contextType + ? (instance.context = contextType.unstable_read()) + : ((contextType = isContextProvider(ctor) + ? previousContext + : contextStackCursor.current), + (instance.context = getMaskedContext(workInProgress, contextType))); + contextType = workInProgress.updateQueue; + null !== contextType && (processUpdateQueue( workInProgress, - unmaskedContext, + contextType, newProps, instance, renderExpirationTime ), (instance.state = workInProgress.memoizedState)); - unmaskedContext = ctor.getDerivedStateFromProps; - "function" === typeof unmaskedContext && - (applyDerivedStateFromProps( - workInProgress, - ctor, - unmaskedContext, - newProps - ), + contextType = ctor.getDerivedStateFromProps; + "function" === typeof contextType && + (applyDerivedStateFromProps(workInProgress, ctor, contextType, newProps), (instance.state = workInProgress.memoizedState)); "function" === typeof ctor.getDerivedStateFromProps || "function" === typeof instance.getSnapshotBeforeUpdate || @@ -2448,11 +2456,11 @@ function mountClassInstance( instance.UNSAFE_componentWillMount(), ctor !== instance.state && classComponentUpdater.enqueueReplaceState(instance, instance.state, null), - (unmaskedContext = workInProgress.updateQueue), - null !== unmaskedContext && + (contextType = workInProgress.updateQueue), + null !== contextType && (processUpdateQueue( workInProgress, - unmaskedContext, + contextType, newProps, instance, renderExpirationTime @@ -2461,7 +2469,7 @@ function mountClassInstance( "function" === typeof instance.componentDidMount && (workInProgress.effectTag |= 4); } -var isArray$1 = Array.isArray; +var isArray = Array.isArray; function coerceRef(returnFiber, current$$1, element) { returnFiber = element.ref; if ( @@ -2475,7 +2483,7 @@ function coerceRef(returnFiber, current$$1, element) { element && (invariant( 2 === element.tag || 3 === element.tag, - "Stateless function components cannot have refs." + "Function components cannot have refs." ), (inst = element.stateNode)); invariant( @@ -2505,7 +2513,7 @@ function coerceRef(returnFiber, current$$1, element) { ); invariant( element._owner, - "Element ref was specified as a string (%s) but no owner was set. This could happen for one of the following reasons:\n1. You may be adding a ref to a functional component\n2. You may be adding a ref to a component that was not created inside a component's render method\n3. You have multiple copies of React loaded\nSee https://fb.me/react-refs-must-have-owner for more information.", + "Element ref was specified as a string (%s) but no owner was set. This could happen for one of the following reasons:\n1. You may be adding a ref to a function component\n2. You may be adding a ref to a component that was not created inside a component's render method\n3. You have multiple copies of React loaded\nSee https://fb.me/react-refs-must-have-owner for more information.", returnFiber ); } @@ -2689,7 +2697,7 @@ function ChildReconciler(shouldTrackSideEffects) { newChild ); } - if (isArray$1(newChild) || getIteratorFn(newChild)) + if (isArray(newChild) || getIteratorFn(newChild)) return ( (newChild = createFiberFromFragment( newChild, @@ -2729,7 +2737,7 @@ function ChildReconciler(shouldTrackSideEffects) { ? updatePortal(returnFiber, oldFiber, newChild, expirationTime) : null; } - if (isArray$1(newChild) || getIteratorFn(newChild)) + if (isArray(newChild) || getIteratorFn(newChild)) return null !== key ? null : updateFragment( @@ -2797,7 +2805,7 @@ function ChildReconciler(shouldTrackSideEffects) { ) ); } - if (isArray$1(newChild) || getIteratorFn(newChild)) + if (isArray(newChild) || getIteratorFn(newChild)) return ( (existingChildren = existingChildren.get(newIdx) || null), updateFragment( @@ -3136,7 +3144,7 @@ function ChildReconciler(shouldTrackSideEffects) { (returnFiber = currentFirstChild)), placeSingleChild(returnFiber) ); - if (isArray$1(newChild)) + if (isArray(newChild)) return reconcileChildrenArray( returnFiber, currentFirstChild, @@ -3297,6 +3305,36 @@ function updateForwardRef( workInProgress.memoizedProps = nextProps; return workInProgress.child; } +function updatePureComponent( + current$$1, + workInProgress, + Component, + nextProps, + updateExpirationTime, + renderExpirationTime +) { + var render = Component.render; + if ( + null !== current$$1 && + (0 === updateExpirationTime || + updateExpirationTime > renderExpirationTime) && + ((updateExpirationTime = current$$1.memoizedProps), + (Component = Component.compare), + (Component = null !== Component ? Component : shallowEqual), + Component(updateExpirationTime, nextProps)) + ) + return bailoutOnAlreadyFinishedWork( + current$$1, + workInProgress, + renderExpirationTime + ); + prepareToReadContext(workInProgress, renderExpirationTime); + render = render(nextProps); + workInProgress.effectTag |= 1; + reconcileChildren(current$$1, workInProgress, render, renderExpirationTime); + workInProgress.memoizedProps = nextProps; + return workInProgress.child; +} function markRef(current$$1, workInProgress) { var ref = workInProgress.ref; if ( @@ -3305,7 +3343,7 @@ function markRef(current$$1, workInProgress) { ) workInProgress.effectTag |= 128; } -function updateFunctionalComponent( +function updateFunctionComponent( current$$1, workInProgress, Component, @@ -3342,15 +3380,21 @@ function updateClassComponent( prepareToReadContext(workInProgress, renderExpirationTime); if (null === current$$1) if (null === workInProgress.stateNode) { - var unmaskedContext = isContextProvider(Component) - ? previousContext - : contextStackCursor.current, - contextTypes = Component.contextTypes, - isContextConsumer = null !== contextTypes && void 0 !== contextTypes; - contextTypes = isContextConsumer - ? getMaskedContext(workInProgress, unmaskedContext) - : emptyContextObject; - var instance = new Component(nextProps, contextTypes); + var isLegacyContextConsumer = !1, + unmaskedContext = emptyContextObject; + var context = Component.contextType; + "object" === typeof context && null !== context + ? (context = context.unstable_read()) + : ((unmaskedContext = isContextProvider(Component) + ? previousContext + : contextStackCursor.current), + (isLegacyContextConsumer = Component.contextTypes), + (context = (isLegacyContextConsumer = + null !== isLegacyContextConsumer && + void 0 !== isLegacyContextConsumer) + ? getMaskedContext(workInProgress, unmaskedContext) + : emptyContextObject)); + var instance = new Component(nextProps, context); workInProgress.memoizedState = null !== instance.state && void 0 !== instance.state ? instance.state @@ -3358,10 +3402,10 @@ function updateClassComponent( instance.updater = classComponentUpdater; workInProgress.stateNode = instance; instance._reactInternalFiber = workInProgress; - isContextConsumer && - ((isContextConsumer = workInProgress.stateNode), - (isContextConsumer.__reactInternalMemoizedUnmaskedChildContext = unmaskedContext), - (isContextConsumer.__reactInternalMemoizedMaskedChildContext = contextTypes)); + isLegacyContextConsumer && + ((isLegacyContextConsumer = workInProgress.stateNode), + (isLegacyContextConsumer.__reactInternalMemoizedUnmaskedChildContext = unmaskedContext), + (isLegacyContextConsumer.__reactInternalMemoizedMaskedChildContext = context)); mountClassInstance( workInProgress, Component, @@ -3371,13 +3415,16 @@ function updateClassComponent( nextProps = !0; } else { unmaskedContext = workInProgress.stateNode; - contextTypes = workInProgress.memoizedProps; - unmaskedContext.props = contextTypes; + isLegacyContextConsumer = workInProgress.memoizedProps; + unmaskedContext.props = isLegacyContextConsumer; var oldContext = unmaskedContext.context; - isContextConsumer = isContextProvider(Component) - ? previousContext - : contextStackCursor.current; - isContextConsumer = getMaskedContext(workInProgress, isContextConsumer); + context = Component.contextType; + "object" === typeof context && null !== context + ? (context = context.unstable_read()) + : ((context = isContextProvider(Component) + ? previousContext + : contextStackCursor.current), + (context = getMaskedContext(workInProgress, context))); var getDerivedStateFromProps = Component.getDerivedStateFromProps; (instance = "function" === typeof getDerivedStateFromProps || @@ -3385,12 +3432,12 @@ function updateClassComponent( ("function" !== typeof unmaskedContext.UNSAFE_componentWillReceiveProps && "function" !== typeof unmaskedContext.componentWillReceiveProps) || - ((contextTypes !== nextProps || oldContext !== isContextConsumer) && + ((isLegacyContextConsumer !== nextProps || oldContext !== context) && callComponentWillReceiveProps( workInProgress, unmaskedContext, nextProps, - isContextConsumer + context )); hasForceUpdate = !1; var oldState = workInProgress.memoizedState; @@ -3405,7 +3452,7 @@ function updateClassComponent( renderExpirationTime ), (oldContext = workInProgress.memoizedState)); - contextTypes !== nextProps || + isLegacyContextConsumer !== nextProps || oldState !== oldContext || didPerformWorkStackCursor.current || hasForceUpdate @@ -3417,16 +3464,16 @@ function updateClassComponent( nextProps ), (oldContext = workInProgress.memoizedState)), - (contextTypes = + (isLegacyContextConsumer = hasForceUpdate || checkShouldComponentUpdate( workInProgress, Component, - contextTypes, + isLegacyContextConsumer, nextProps, oldState, oldContext, - isContextConsumer + context )) ? (instance || ("function" !== @@ -3445,21 +3492,24 @@ function updateClassComponent( (workInProgress.memoizedState = oldContext)), (unmaskedContext.props = nextProps), (unmaskedContext.state = oldContext), - (unmaskedContext.context = isContextConsumer), - (nextProps = contextTypes)) + (unmaskedContext.context = context), + (nextProps = isLegacyContextConsumer)) : ("function" === typeof unmaskedContext.componentDidMount && (workInProgress.effectTag |= 4), (nextProps = !1)); } else (unmaskedContext = workInProgress.stateNode), - (contextTypes = workInProgress.memoizedProps), - (unmaskedContext.props = contextTypes), + (isLegacyContextConsumer = workInProgress.memoizedProps), + (unmaskedContext.props = isLegacyContextConsumer), (oldContext = unmaskedContext.context), - (isContextConsumer = isContextProvider(Component) - ? previousContext - : contextStackCursor.current), - (isContextConsumer = getMaskedContext(workInProgress, isContextConsumer)), + (context = Component.contextType), + "object" === typeof context && null !== context + ? (context = context.unstable_read()) + : ((context = isContextProvider(Component) + ? previousContext + : contextStackCursor.current), + (context = getMaskedContext(workInProgress, context))), (getDerivedStateFromProps = Component.getDerivedStateFromProps), (instance = "function" === typeof getDerivedStateFromProps || @@ -3467,12 +3517,12 @@ function updateClassComponent( ("function" !== typeof unmaskedContext.UNSAFE_componentWillReceiveProps && "function" !== typeof unmaskedContext.componentWillReceiveProps) || - ((contextTypes !== nextProps || oldContext !== isContextConsumer) && + ((isLegacyContextConsumer !== nextProps || oldContext !== context) && callComponentWillReceiveProps( workInProgress, unmaskedContext, nextProps, - isContextConsumer + context )), (hasForceUpdate = !1), (oldContext = workInProgress.memoizedState), @@ -3487,7 +3537,7 @@ function updateClassComponent( renderExpirationTime ), (oldState = workInProgress.memoizedState)), - contextTypes !== nextProps || + isLegacyContextConsumer !== nextProps || oldContext !== oldState || didPerformWorkStackCursor.current || hasForceUpdate @@ -3504,11 +3554,11 @@ function updateClassComponent( checkShouldComponentUpdate( workInProgress, Component, - contextTypes, + isLegacyContextConsumer, nextProps, oldContext, oldState, - isContextConsumer + context )) ? (instance || ("function" !== @@ -3518,39 +3568,39 @@ function updateClassComponent( unmaskedContext.componentWillUpdate( nextProps, oldState, - isContextConsumer + context ), "function" === typeof unmaskedContext.UNSAFE_componentWillUpdate && unmaskedContext.UNSAFE_componentWillUpdate( nextProps, oldState, - isContextConsumer + context )), "function" === typeof unmaskedContext.componentDidUpdate && (workInProgress.effectTag |= 4), "function" === typeof unmaskedContext.getSnapshotBeforeUpdate && (workInProgress.effectTag |= 256)) : ("function" !== typeof unmaskedContext.componentDidUpdate || - (contextTypes === current$$1.memoizedProps && + (isLegacyContextConsumer === current$$1.memoizedProps && oldContext === current$$1.memoizedState) || (workInProgress.effectTag |= 4), "function" !== typeof unmaskedContext.getSnapshotBeforeUpdate || - (contextTypes === current$$1.memoizedProps && + (isLegacyContextConsumer === current$$1.memoizedProps && oldContext === current$$1.memoizedState) || (workInProgress.effectTag |= 256), (workInProgress.memoizedProps = nextProps), (workInProgress.memoizedState = oldState)), (unmaskedContext.props = nextProps), (unmaskedContext.state = oldState), - (unmaskedContext.context = isContextConsumer), + (unmaskedContext.context = context), (nextProps = getDerivedStateFromProps)) : ("function" !== typeof unmaskedContext.componentDidUpdate || - (contextTypes === current$$1.memoizedProps && + (isLegacyContextConsumer === current$$1.memoizedProps && oldContext === current$$1.memoizedState) || (workInProgress.effectTag |= 4), "function" !== typeof unmaskedContext.getSnapshotBeforeUpdate || - (contextTypes === current$$1.memoizedProps && + (isLegacyContextConsumer === current$$1.memoizedProps && oldContext === current$$1.memoizedState) || (workInProgress.effectTag |= 256), (nextProps = !1)); @@ -3584,18 +3634,30 @@ function finishClassComponent( ); shouldUpdate = workInProgress.stateNode; ReactCurrentOwner$3.current = workInProgress; - var nextChildren = didCaptureError ? null : shouldUpdate.render(); + var nextChildren = + didCaptureError && "function" !== typeof Component.getDerivedStateFromError + ? null + : shouldUpdate.render(); workInProgress.effectTag |= 1; - null !== current$$1 && - didCaptureError && - (reconcileChildren(current$$1, workInProgress, null, renderExpirationTime), - (workInProgress.child = null)); - reconcileChildren( - current$$1, - workInProgress, - nextChildren, - renderExpirationTime - ); + null !== current$$1 && didCaptureError + ? ((workInProgress.child = reconcileChildFibers( + workInProgress, + current$$1.child, + null, + renderExpirationTime + )), + (workInProgress.child = reconcileChildFibers( + workInProgress, + null, + nextChildren, + renderExpirationTime + ))) + : reconcileChildren( + current$$1, + workInProgress, + nextChildren, + renderExpirationTime + ); workInProgress.memoizedState = shouldUpdate.state; workInProgress.memoizedProps = shouldUpdate.props; hasContext && invalidateContextProvider(workInProgress, Component, !0); @@ -3623,122 +3685,6 @@ function resolveDefaultProps(Component, baseProps) { } return baseProps; } -function mountIndeterminateComponent( - current$$1, - workInProgress, - Component, - renderExpirationTime -) { - invariant( - null === current$$1, - "An indeterminate component should never have mounted. This error is likely caused by a bug in React. Please file an issue." - ); - var props = workInProgress.pendingProps; - if ( - "object" === typeof Component && - null !== Component && - "function" === typeof Component.then - ) { - Component = readLazyComponentType(Component); - var JSCompiler_inline_result = Component; - JSCompiler_inline_result = - "function" === typeof JSCompiler_inline_result - ? shouldConstruct(JSCompiler_inline_result) - ? 3 - : 1 - : void 0 !== JSCompiler_inline_result && - null !== JSCompiler_inline_result && - JSCompiler_inline_result.$$typeof - ? 14 - : 4; - JSCompiler_inline_result = workInProgress.tag = JSCompiler_inline_result; - var resolvedProps = resolveDefaultProps(Component, props); - switch (JSCompiler_inline_result) { - case 1: - return updateFunctionalComponent( - current$$1, - workInProgress, - Component, - resolvedProps, - renderExpirationTime - ); - case 3: - return updateClassComponent( - current$$1, - workInProgress, - Component, - resolvedProps, - renderExpirationTime - ); - case 14: - return updateForwardRef( - current$$1, - workInProgress, - Component, - resolvedProps, - renderExpirationTime - ); - default: - invariant( - !1, - "Element type is invalid. Received a promise that resolves to: %s. Promise elements must resolve to a class or function.", - Component - ); - } - } - JSCompiler_inline_result = getMaskedContext( - workInProgress, - contextStackCursor.current - ); - prepareToReadContext(workInProgress, renderExpirationTime); - JSCompiler_inline_result = Component(props, JSCompiler_inline_result); - workInProgress.effectTag |= 1; - if ( - "object" === typeof JSCompiler_inline_result && - null !== JSCompiler_inline_result && - "function" === typeof JSCompiler_inline_result.render && - void 0 === JSCompiler_inline_result.$$typeof - ) { - workInProgress.tag = 2; - isContextProvider(Component) - ? ((resolvedProps = !0), pushContextProvider(workInProgress)) - : (resolvedProps = !1); - workInProgress.memoizedState = - null !== JSCompiler_inline_result.state && - void 0 !== JSCompiler_inline_result.state - ? JSCompiler_inline_result.state - : null; - var getDerivedStateFromProps = Component.getDerivedStateFromProps; - "function" === typeof getDerivedStateFromProps && - applyDerivedStateFromProps( - workInProgress, - Component, - getDerivedStateFromProps, - props - ); - JSCompiler_inline_result.updater = classComponentUpdater; - workInProgress.stateNode = JSCompiler_inline_result; - JSCompiler_inline_result._reactInternalFiber = workInProgress; - mountClassInstance(workInProgress, Component, props, renderExpirationTime); - return finishClassComponent( - current$$1, - workInProgress, - Component, - !0, - resolvedProps, - renderExpirationTime - ); - } - workInProgress.tag = 0; - reconcileChildren( - current$$1, - workInProgress, - JSCompiler_inline_result, - renderExpirationTime - ); - workInProgress.memoizedProps = props; - return workInProgress.child; -} function bailoutOnAlreadyFinishedWork( current$$1, workInProgress, @@ -3780,6 +3726,8 @@ function bailoutOnAlreadyFinishedWork( function beginWork(current$$1, workInProgress, renderExpirationTime) { var updateExpirationTime = workInProgress.expirationTime; if ( + null !== current$$1 && + current$$1.memoizedProps === workInProgress.pendingProps && !didPerformWorkStackCursor.current && (0 === updateExpirationTime || updateExpirationTime > renderExpirationTime) ) { @@ -3816,14 +3764,129 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { workInProgress.expirationTime = 0; switch (workInProgress.tag) { case 4: - return mountIndeterminateComponent( - current$$1, - workInProgress, - workInProgress.type, - renderExpirationTime + var Component = workInProgress.type; + invariant( + null === current$$1, + "An indeterminate component should never have mounted. This error is likely caused by a bug in React. Please file an issue." ); + var props = workInProgress.pendingProps; + if ( + "object" === typeof Component && + null !== Component && + "function" === typeof Component.then + ) { + Component = readLazyComponentType(Component); + var resolvedTag = (workInProgress.tag = resolveLazyComponentTag( + workInProgress, + Component + )), + resolvedProps = resolveDefaultProps(Component, props), + child = void 0; + switch (resolvedTag) { + case 1: + child = updateFunctionComponent( + current$$1, + workInProgress, + Component, + resolvedProps, + renderExpirationTime + ); + break; + case 3: + child = updateClassComponent( + current$$1, + workInProgress, + Component, + resolvedProps, + renderExpirationTime + ); + break; + case 14: + child = updateForwardRef( + current$$1, + workInProgress, + Component, + resolvedProps, + renderExpirationTime + ); + break; + case 18: + child = updatePureComponent( + current$$1, + workInProgress, + Component, + resolvedProps, + updateExpirationTime, + renderExpirationTime + ); + break; + default: + invariant( + !1, + "Element type is invalid. Received a promise that resolves to: %s. Promise elements must resolve to a class or function.", + Component + ); + } + workInProgress.memoizedProps = props; + workInProgress = child; + } else + (updateExpirationTime = getMaskedContext( + workInProgress, + contextStackCursor.current + )), + prepareToReadContext(workInProgress, renderExpirationTime), + (updateExpirationTime = Component(props, updateExpirationTime)), + (workInProgress.effectTag |= 1), + "object" === typeof updateExpirationTime && + null !== updateExpirationTime && + "function" === typeof updateExpirationTime.render && + void 0 === updateExpirationTime.$$typeof + ? ((workInProgress.tag = 2), + isContextProvider(Component) + ? ((resolvedTag = !0), pushContextProvider(workInProgress)) + : (resolvedTag = !1), + (workInProgress.memoizedState = + null !== updateExpirationTime.state && + void 0 !== updateExpirationTime.state + ? updateExpirationTime.state + : null), + (resolvedProps = Component.getDerivedStateFromProps), + "function" === typeof resolvedProps && + applyDerivedStateFromProps( + workInProgress, + Component, + resolvedProps, + props + ), + (updateExpirationTime.updater = classComponentUpdater), + (workInProgress.stateNode = updateExpirationTime), + (updateExpirationTime._reactInternalFiber = workInProgress), + mountClassInstance( + workInProgress, + Component, + props, + renderExpirationTime + ), + (workInProgress = finishClassComponent( + current$$1, + workInProgress, + Component, + !0, + resolvedTag, + renderExpirationTime + ))) + : ((workInProgress.tag = 0), + reconcileChildren( + current$$1, + workInProgress, + updateExpirationTime, + renderExpirationTime + ), + (workInProgress.memoizedProps = props), + (workInProgress = workInProgress.child)); + return workInProgress; case 0: - return updateFunctionalComponent( + return updateFunctionComponent( current$$1, workInProgress, workInProgress.type, @@ -3831,17 +3894,19 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { renderExpirationTime ); case 1: - var _Component5 = workInProgress.type._reactResult; - updateExpirationTime = workInProgress.pendingProps; - current$$1 = updateFunctionalComponent( - current$$1, - workInProgress, - _Component5, - resolveDefaultProps(_Component5, updateExpirationTime), - renderExpirationTime + return ( + (props = workInProgress.type._reactResult), + (Component = workInProgress.pendingProps), + (current$$1 = updateFunctionComponent( + current$$1, + workInProgress, + props, + resolveDefaultProps(props, Component), + renderExpirationTime + )), + (workInProgress.memoizedProps = Component), + current$$1 ); - workInProgress.memoizedProps = updateExpirationTime; - return current$$1; case 2: return updateClassComponent( current$$1, @@ -3852,37 +3917,37 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { ); case 3: return ( - (_Component5 = workInProgress.type._reactResult), - (updateExpirationTime = workInProgress.pendingProps), + (props = workInProgress.type._reactResult), + (Component = workInProgress.pendingProps), (current$$1 = updateClassComponent( current$$1, workInProgress, - _Component5, - resolveDefaultProps(_Component5, updateExpirationTime), + props, + resolveDefaultProps(props, Component), renderExpirationTime )), - (workInProgress.memoizedProps = updateExpirationTime), + (workInProgress.memoizedProps = Component), current$$1 ); case 5: return ( pushHostRootContext(workInProgress), - (updateExpirationTime = workInProgress.updateQueue), + (Component = workInProgress.updateQueue), invariant( - null !== updateExpirationTime, + null !== Component, "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." ), - (_Component5 = workInProgress.memoizedState), - (_Component5 = null !== _Component5 ? _Component5.element : null), + (props = workInProgress.memoizedState), + (props = null !== props ? props.element : null), processUpdateQueue( workInProgress, - updateExpirationTime, + Component, workInProgress.pendingProps, null, renderExpirationTime ), - (updateExpirationTime = workInProgress.memoizedState.element), - updateExpirationTime === _Component5 + (Component = workInProgress.memoizedState.element), + Component === props ? (workInProgress = bailoutOnAlreadyFinishedWork( current$$1, workInProgress, @@ -3891,7 +3956,7 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { : (reconcileChildren( current$$1, workInProgress, - updateExpirationTime, + Component, renderExpirationTime ), (workInProgress = workInProgress.child)), @@ -3901,16 +3966,16 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { return ( pushHostContext(workInProgress), null === current$$1 && tryToClaimNextHydratableInstance(workInProgress), - (updateExpirationTime = workInProgress.pendingProps), - (_Component5 = updateExpirationTime.children), + (Component = workInProgress.pendingProps), + (props = Component.children), markRef(current$$1, workInProgress), reconcileChildren( current$$1, workInProgress, - _Component5, + props, renderExpirationTime ), - (workInProgress.memoizedProps = updateExpirationTime), + (workInProgress.memoizedProps = Component), (workInProgress = workInProgress.child), workInProgress ); @@ -3928,21 +3993,21 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { workInProgress, workInProgress.stateNode.containerInfo ), - (updateExpirationTime = workInProgress.pendingProps), + (Component = workInProgress.pendingProps), null === current$$1 ? (workInProgress.child = reconcileChildFibers( workInProgress, null, - updateExpirationTime, + Component, renderExpirationTime )) : reconcileChildren( current$$1, workInProgress, - updateExpirationTime, + Component, renderExpirationTime ), - (workInProgress.memoizedProps = updateExpirationTime), + (workInProgress.memoizedProps = Component), workInProgress.child ); case 13: @@ -3955,79 +4020,82 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { ); case 14: return ( - (_Component5 = workInProgress.type._reactResult), - (updateExpirationTime = workInProgress.pendingProps), + (props = workInProgress.type._reactResult), + (Component = workInProgress.pendingProps), (current$$1 = updateForwardRef( current$$1, workInProgress, - _Component5, - resolveDefaultProps(_Component5, updateExpirationTime), + props, + resolveDefaultProps(props, Component), renderExpirationTime )), - (workInProgress.memoizedProps = updateExpirationTime), + (workInProgress.memoizedProps = Component), current$$1 ); case 9: return ( - (updateExpirationTime = workInProgress.pendingProps), + (Component = workInProgress.pendingProps), reconcileChildren( current$$1, workInProgress, - updateExpirationTime, + Component, renderExpirationTime ), - (workInProgress.memoizedProps = updateExpirationTime), + (workInProgress.memoizedProps = Component), workInProgress.child ); case 10: return ( - (updateExpirationTime = workInProgress.pendingProps.children), + (Component = workInProgress.pendingProps.children), reconcileChildren( current$$1, workInProgress, - updateExpirationTime, + Component, renderExpirationTime ), - (workInProgress.memoizedProps = updateExpirationTime), + (workInProgress.memoizedProps = Component), workInProgress.child ); case 15: return ( - (updateExpirationTime = workInProgress.pendingProps), + (Component = workInProgress.pendingProps), reconcileChildren( current$$1, workInProgress, - updateExpirationTime.children, + Component.children, renderExpirationTime ), - (workInProgress.memoizedProps = updateExpirationTime), + (workInProgress.memoizedProps = Component), workInProgress.child ); case 12: a: { - updateExpirationTime = workInProgress.type._context; - _Component5 = workInProgress.pendingProps; - var oldProps = workInProgress.memoizedProps, - newValue = _Component5.value; - workInProgress.memoizedProps = _Component5; - pushProvider(workInProgress, newValue); - if (null !== oldProps) { - var oldValue = oldProps.value; - newValue = - (oldValue === newValue && - (0 !== oldValue || 1 / oldValue === 1 / newValue)) || - (oldValue !== oldValue && newValue !== newValue) - ? 0 - : ("function" === - typeof updateExpirationTime._calculateChangedBits - ? updateExpirationTime._calculateChangedBits( - oldValue, - newValue - ) - : 1073741823) | 0; - if (0 === newValue) { + Component = workInProgress.type._context; + props = workInProgress.pendingProps; + resolvedTag = workInProgress.memoizedProps; + updateExpirationTime = props.value; + workInProgress.memoizedProps = props; + pushProvider(workInProgress, updateExpirationTime); + if (null !== resolvedTag) + if ( + ((resolvedProps = resolvedTag.value), + (updateExpirationTime = + (resolvedProps === updateExpirationTime && + (0 !== resolvedProps || + 1 / resolvedProps === 1 / updateExpirationTime)) || + (resolvedProps !== resolvedProps && + updateExpirationTime !== updateExpirationTime) + ? 0 + : ("function" === typeof Component._calculateChangedBits + ? Component._calculateChangedBits( + resolvedProps, + updateExpirationTime + ) + : 1073741823) | 0), + 0 === updateExpirationTime) + ) { if ( - oldProps.children === _Component5.children && + resolvedTag.children === props.children && !didPerformWorkStackCursor.current ) { workInProgress = bailoutOnAlreadyFinishedWork( @@ -4039,87 +4107,85 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { } } else for ( - oldProps = workInProgress.child, - null !== oldProps && (oldProps.return = workInProgress); - null !== oldProps; + resolvedTag = workInProgress.child, + null !== resolvedTag && (resolvedTag.return = workInProgress); + null !== resolvedTag; ) { - oldValue = oldProps.firstContextDependency; - if (null !== oldValue) { + resolvedProps = resolvedTag.firstContextDependency; + if (null !== resolvedProps) { do { if ( - oldValue.context === updateExpirationTime && - 0 !== (oldValue.observedBits & newValue) + resolvedProps.context === Component && + 0 !== (resolvedProps.observedBits & updateExpirationTime) ) { - if (2 === oldProps.tag || 3 === oldProps.tag) { - var nextFiber = createUpdate(renderExpirationTime); - nextFiber.tag = 2; - enqueueUpdate(oldProps, nextFiber); - } + if (2 === resolvedTag.tag || 3 === resolvedTag.tag) + (child = createUpdate(renderExpirationTime)), + (child.tag = 2), + enqueueUpdate(resolvedTag, child); if ( - 0 === oldProps.expirationTime || - oldProps.expirationTime > renderExpirationTime + 0 === resolvedTag.expirationTime || + resolvedTag.expirationTime > renderExpirationTime ) - oldProps.expirationTime = renderExpirationTime; - nextFiber = oldProps.alternate; - null !== nextFiber && - (0 === nextFiber.expirationTime || - nextFiber.expirationTime > renderExpirationTime) && - (nextFiber.expirationTime = renderExpirationTime); - for (var node = oldProps.return; null !== node; ) { - nextFiber = node.alternate; + resolvedTag.expirationTime = renderExpirationTime; + child = resolvedTag.alternate; + null !== child && + (0 === child.expirationTime || + child.expirationTime > renderExpirationTime) && + (child.expirationTime = renderExpirationTime); + for (var node = resolvedTag.return; null !== node; ) { + child = node.alternate; if ( 0 === node.childExpirationTime || node.childExpirationTime > renderExpirationTime ) (node.childExpirationTime = renderExpirationTime), - null !== nextFiber && - (0 === nextFiber.childExpirationTime || - nextFiber.childExpirationTime > + null !== child && + (0 === child.childExpirationTime || + child.childExpirationTime > renderExpirationTime) && - (nextFiber.childExpirationTime = renderExpirationTime); + (child.childExpirationTime = renderExpirationTime); else if ( - null !== nextFiber && - (0 === nextFiber.childExpirationTime || - nextFiber.childExpirationTime > renderExpirationTime) + null !== child && + (0 === child.childExpirationTime || + child.childExpirationTime > renderExpirationTime) ) - nextFiber.childExpirationTime = renderExpirationTime; + child.childExpirationTime = renderExpirationTime; else break; node = node.return; } } - nextFiber = oldProps.child; - oldValue = oldValue.next; - } while (null !== oldValue); + child = resolvedTag.child; + resolvedProps = resolvedProps.next; + } while (null !== resolvedProps); } else - nextFiber = - 12 === oldProps.tag - ? oldProps.type === workInProgress.type + child = + 12 === resolvedTag.tag + ? resolvedTag.type === workInProgress.type ? null - : oldProps.child - : oldProps.child; - if (null !== nextFiber) nextFiber.return = oldProps; + : resolvedTag.child + : resolvedTag.child; + if (null !== child) child.return = resolvedTag; else - for (nextFiber = oldProps; null !== nextFiber; ) { - if (nextFiber === workInProgress) { - nextFiber = null; + for (child = resolvedTag; null !== child; ) { + if (child === workInProgress) { + child = null; break; } - oldProps = nextFiber.sibling; - if (null !== oldProps) { - oldProps.return = nextFiber.return; - nextFiber = oldProps; + resolvedTag = child.sibling; + if (null !== resolvedTag) { + resolvedTag.return = child.return; + child = resolvedTag; break; } - nextFiber = nextFiber.return; + child = child.return; } - oldProps = nextFiber; + resolvedTag = child; } - } reconcileChildren( current$$1, workInProgress, - _Component5.children, + props.children, renderExpirationTime ); workInProgress = workInProgress.child; @@ -4127,25 +4193,49 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { return workInProgress; case 11: return ( - (newValue = workInProgress.type), - (updateExpirationTime = workInProgress.pendingProps), - (_Component5 = updateExpirationTime.children), + (updateExpirationTime = workInProgress.type), + (Component = workInProgress.pendingProps), + (props = Component.children), prepareToReadContext(workInProgress, renderExpirationTime), - (newValue = readContext( - newValue, - updateExpirationTime.unstable_observedBits + (updateExpirationTime = readContext( + updateExpirationTime, + Component.unstable_observedBits )), - (_Component5 = _Component5(newValue)), + (props = props(updateExpirationTime)), (workInProgress.effectTag |= 1), reconcileChildren( current$$1, workInProgress, - _Component5, + props, renderExpirationTime ), - (workInProgress.memoizedProps = updateExpirationTime), + (workInProgress.memoizedProps = Component), workInProgress.child ); + case 17: + return updatePureComponent( + current$$1, + workInProgress, + workInProgress.type, + workInProgress.pendingProps, + updateExpirationTime, + renderExpirationTime + ); + case 18: + return ( + (props = workInProgress.type._reactResult), + (Component = workInProgress.pendingProps), + (current$$1 = updatePureComponent( + current$$1, + workInProgress, + props, + resolveDefaultProps(props, Component), + updateExpirationTime, + renderExpirationTime + )), + (workInProgress.memoizedProps = Component), + current$$1 + ); default: invariant( !1, @@ -4548,13 +4638,21 @@ function createRootErrorUpdate(fiber, errorInfo, expirationTime) { function createClassErrorUpdate(fiber, errorInfo, expirationTime) { expirationTime = createUpdate(expirationTime); expirationTime.tag = 3; + var getDerivedStateFromError = fiber.type.getDerivedStateFromError; + if ("function" === typeof getDerivedStateFromError) { + var error$jscomp$0 = errorInfo.value; + expirationTime.payload = function() { + return getDerivedStateFromError(error$jscomp$0); + }; + } var inst = fiber.stateNode; null !== inst && "function" === typeof inst.componentDidCatch && (expirationTime.callback = function() { - null === legacyErrorBoundariesThatAlreadyFailed - ? (legacyErrorBoundariesThatAlreadyFailed = new Set([this])) - : legacyErrorBoundariesThatAlreadyFailed.add(this); + "function" !== typeof getDerivedStateFromError && + (null === legacyErrorBoundariesThatAlreadyFailed + ? (legacyErrorBoundariesThatAlreadyFailed = new Set([this])) + : legacyErrorBoundariesThatAlreadyFailed.add(this)); var error = errorInfo.value, stack = errorInfo.stack; logError(fiber, errorInfo); @@ -4827,6 +4925,9 @@ function completeUnitOfWork(workInProgress) { break; case 11: break; + case 17: + case 18: + break; case 4: invariant( !1, @@ -4838,31 +4939,28 @@ function completeUnitOfWork(workInProgress) { "Unknown unit of work tag. This error is likely caused by a bug in React. Please file an issue." ); } - current$$1 = nextUnitOfWork = null; - newProps = workInProgress; + nextUnitOfWork = null; + current$$1 = workInProgress; if ( 1073741823 === nextRenderExpirationTime || - 1073741823 !== newProps.childExpirationTime + 1073741823 !== current$$1.childExpirationTime ) { - rootContainerInstance = 0; - for (type = newProps.child; null !== type; ) { - current = type.expirationTime; - viewConfig = type.childExpirationTime; - if ( - 0 === rootContainerInstance || - (0 !== current && current < rootContainerInstance) - ) - rootContainerInstance = current; - if ( - 0 === rootContainerInstance || - (0 !== viewConfig && viewConfig < rootContainerInstance) - ) - rootContainerInstance = viewConfig; - type = type.sibling; + newProps = 0; + for ( + rootContainerInstance = current$$1.child; + null !== rootContainerInstance; + + ) { + type = rootContainerInstance.expirationTime; + current = rootContainerInstance.childExpirationTime; + if (0 === newProps || (0 !== type && type < newProps)) + newProps = type; + if (0 === newProps || (0 !== current && current < newProps)) + newProps = current; + rootContainerInstance = rootContainerInstance.sibling; } - newProps.childExpirationTime = rootContainerInstance; + current$$1.childExpirationTime = newProps; } - if (null !== current$$1) return current$$1; null !== returnFiber && 0 === (returnFiber.effectTag & 512) && (null === returnFiber.firstEffect && @@ -4967,13 +5065,17 @@ function renderRoot(root, isYieldy, isExpired) { case 2: case 3: sourceFiber$jscomp$0 = value; - var instance = returnFiber$jscomp$0.stateNode; + var ctor = returnFiber$jscomp$0.type, + instance = returnFiber$jscomp$0.stateNode; if ( 0 === (returnFiber$jscomp$0.effectTag & 64) && - null !== instance && - "function" === typeof instance.componentDidCatch && - (null === legacyErrorBoundariesThatAlreadyFailed || - !legacyErrorBoundariesThatAlreadyFailed.has(instance)) + ("function" === typeof ctor.getDerivedStateFromError || + (null !== instance && + "function" === typeof instance.componentDidCatch && + (null === legacyErrorBoundariesThatAlreadyFailed || + !legacyErrorBoundariesThatAlreadyFailed.has( + instance + )))) ) { returnFiber$jscomp$0.effectTag |= 1024; returnFiber$jscomp$0.expirationTime = returnFiber; @@ -5070,7 +5172,7 @@ function captureCommitPhaseError(fiber, error) { var instance = JSCompiler_inline_result.stateNode; if ( "function" === - typeof JSCompiler_inline_result.type.getDerivedStateFromCatch || + typeof JSCompiler_inline_result.type.getDerivedStateFromError || ("function" === typeof instance.componentDidCatch && (null === legacyErrorBoundariesThatAlreadyFailed || !legacyErrorBoundariesThatAlreadyFailed.has(instance))) @@ -5118,43 +5220,40 @@ function computeExpirationForFiber(currentTime, fiber) { (currentTime += 1)) : (currentTime = 1); isBatchingInteractiveUpdates && - (0 === lowestPriorityPendingInteractiveExpirationTime || - currentTime > lowestPriorityPendingInteractiveExpirationTime) && + currentTime > lowestPriorityPendingInteractiveExpirationTime && (lowestPriorityPendingInteractiveExpirationTime = currentTime); return currentTime; } function scheduleWork(fiber, expirationTime) { - a: { - if (0 === fiber.expirationTime || fiber.expirationTime > expirationTime) - fiber.expirationTime = expirationTime; - var alternate = fiber.alternate; - null !== alternate && - (0 === alternate.expirationTime || - alternate.expirationTime > expirationTime) && - (alternate.expirationTime = expirationTime); - var node = fiber.return; - if (null === node && 5 === fiber.tag) fiber = fiber.stateNode; - else { - for (; null !== node; ) { - alternate = node.alternate; - if ( - 0 === node.childExpirationTime || - node.childExpirationTime > expirationTime - ) - node.childExpirationTime = expirationTime; - null !== alternate && - (0 === alternate.childExpirationTime || - alternate.childExpirationTime > expirationTime) && - (alternate.childExpirationTime = expirationTime); - if (null === node.return && 5 === node.tag) { - fiber = node.stateNode; - break a; - } - node = node.return; + if (0 === fiber.expirationTime || fiber.expirationTime > expirationTime) + fiber.expirationTime = expirationTime; + var alternate = fiber.alternate; + null !== alternate && + (0 === alternate.expirationTime || + alternate.expirationTime > expirationTime) && + (alternate.expirationTime = expirationTime); + var node = fiber.return, + root = null; + if (null === node && 5 === fiber.tag) root = fiber.stateNode; + else + for (; null !== node; ) { + alternate = node.alternate; + if ( + 0 === node.childExpirationTime || + node.childExpirationTime > expirationTime + ) + node.childExpirationTime = expirationTime; + null !== alternate && + (0 === alternate.childExpirationTime || + alternate.childExpirationTime > expirationTime) && + (alternate.childExpirationTime = expirationTime); + if (null === node.return && 5 === node.tag) { + root = node.stateNode; + break; } - fiber = null; + node = node.return; } - } + fiber = null === root ? null : root; if (null !== fiber) { !isWorking && 0 !== nextRenderExpirationTime && @@ -5162,29 +5261,28 @@ function scheduleWork(fiber, expirationTime) { resetStack(); markPendingPriorityLevel(fiber, expirationTime); if (!isWorking || isCommitting$1 || nextRoot !== fiber) { - expirationTime = fiber; - fiber = fiber.expirationTime; - if (null === expirationTime.nextScheduledRoot) - (expirationTime.expirationTime = fiber), + expirationTime = fiber.expirationTime; + if (null === fiber.nextScheduledRoot) + (fiber.expirationTime = expirationTime), null === lastScheduledRoot - ? ((firstScheduledRoot = lastScheduledRoot = expirationTime), - (expirationTime.nextScheduledRoot = expirationTime)) - : ((lastScheduledRoot = lastScheduledRoot.nextScheduledRoot = expirationTime), + ? ((firstScheduledRoot = lastScheduledRoot = fiber), + (fiber.nextScheduledRoot = fiber)) + : ((lastScheduledRoot = lastScheduledRoot.nextScheduledRoot = fiber), (lastScheduledRoot.nextScheduledRoot = firstScheduledRoot)); else if ( - ((alternate = expirationTime.expirationTime), - 0 === alternate || fiber < alternate) + ((alternate = fiber.expirationTime), + 0 === alternate || expirationTime < alternate) ) - expirationTime.expirationTime = fiber; + fiber.expirationTime = expirationTime; isRendering || (isBatchingUpdates ? isUnbatchingUpdates && - ((nextFlushedRoot = expirationTime), + ((nextFlushedRoot = fiber), (nextFlushedExpirationTime = 1), - performWorkOnRoot(expirationTime, 1, !0)) - : 1 === fiber + performWorkOnRoot(fiber, 1, !0)) + : 1 === expirationTime ? performWork(1, null) - : scheduleCallbackWithExpirationTime(expirationTime, fiber)); + : scheduleCallbackWithExpirationTime(fiber, expirationTime)); } nestedUpdateCount > NESTED_UPDATE_LIMIT && ((nestedUpdateCount = 0), @@ -6063,7 +6161,7 @@ var roots = new Map(), findFiberByHostInstance: getInstanceFromTag, getInspectorDataForViewTag: getInspectorDataForViewTag, bundleType: 0, - version: "16.5.0", + version: "16.5.2", rendererPackageName: "react-native-renderer" }); var ReactNativeRenderer$2 = { default: ReactNativeRenderer }, diff --git a/Libraries/Renderer/oss/ReactNativeRenderer-profiling.js b/Libraries/Renderer/oss/ReactNativeRenderer-profiling.js index f9c2b56db17e78..a8566250cae58a 100644 --- a/Libraries/Renderer/oss/ReactNativeRenderer-profiling.js +++ b/Libraries/Renderer/oss/ReactNativeRenderer-profiling.js @@ -19,7 +19,7 @@ var ReactNativeViewConfigRegistry = require("ReactNativeViewConfigRegistry"), deepDiffer = require("deepDiffer"), flattenStyle = require("flattenStyle"), TextInputState = require("TextInputState"), - tracking = require("schedule/tracking"), + tracing = require("scheduler/tracing"), ExceptionsManager = require("ExceptionsManager"); function invariant(condition, format, a, b, c, d, e, f) { if (!condition) { @@ -1143,9 +1143,12 @@ var ReactSharedInternals = REACT_PROFILER_TYPE = hasSymbol ? Symbol.for("react.profiler") : 60114, REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for("react.provider") : 60109, REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for("react.context") : 60110, - REACT_ASYNC_MODE_TYPE = hasSymbol ? Symbol.for("react.async_mode") : 60111, + REACT_CONCURRENT_MODE_TYPE = hasSymbol + ? Symbol.for("react.concurrent_mode") + : 60111, REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for("react.forward_ref") : 60112, REACT_PLACEHOLDER_TYPE = hasSymbol ? Symbol.for("react.placeholder") : 60113, + REACT_PURE_TYPE = hasSymbol ? Symbol.for("react.pure") : 60115, MAYBE_ITERATOR_SYMBOL = "function" === typeof Symbol && Symbol.iterator; function getIteratorFn(maybeIterable) { if (null === maybeIterable || "object" !== typeof maybeIterable) return null; @@ -1159,8 +1162,8 @@ function getComponentName(type) { if ("function" === typeof type) return type.displayName || type.name || null; if ("string" === typeof type) return type; switch (type) { - case REACT_ASYNC_MODE_TYPE: - return "AsyncMode"; + case REACT_CONCURRENT_MODE_TYPE: + return "ConcurrentMode"; case REACT_FRAGMENT_TYPE: return "Fragment"; case REACT_PORTAL_TYPE: @@ -1179,10 +1182,11 @@ function getComponentName(type) { case REACT_PROVIDER_TYPE: return "Context.Provider"; case REACT_FORWARD_REF_TYPE: + var renderFn = type.render; + renderFn = renderFn.displayName || renderFn.name || ""; return ( - (type = type.render), - (type = type.displayName || type.name || ""), - "" !== type ? "ForwardRef(" + type + ")" : "ForwardRef" + type.displayName || + ("" !== renderFn ? "ForwardRef(" + renderFn + ")" : "ForwardRef") ); } if ( @@ -1819,7 +1823,17 @@ function shouldConstruct(Component) { Component = Component.prototype; return !(!Component || !Component.isReactComponent); } -function createWorkInProgress(current, pendingProps, expirationTime) { +function resolveLazyComponentTag(fiber, Component) { + if ("function" === typeof Component) + return shouldConstruct(Component) ? 3 : 1; + if (void 0 !== Component && null !== Component) { + fiber = Component.$$typeof; + if (fiber === REACT_FORWARD_REF_TYPE) return 14; + if (fiber === REACT_PURE_TYPE) return 18; + } + return 4; +} +function createWorkInProgress(current, pendingProps) { var workInProgress = current.alternate; null === workInProgress ? ((workInProgress = new FiberNode( @@ -1840,10 +1854,7 @@ function createWorkInProgress(current, pendingProps, expirationTime) { (workInProgress.actualDuration = 0), (workInProgress.actualStartTime = -1)); workInProgress.childExpirationTime = current.childExpirationTime; - workInProgress.expirationTime = - pendingProps !== current.pendingProps - ? expirationTime - : current.expirationTime; + workInProgress.expirationTime = current.expirationTime; workInProgress.child = current.child; workInProgress.memoizedProps = current.memoizedProps; workInProgress.memoizedState = current.memoizedState; @@ -1872,7 +1883,7 @@ function createFiberFromElement(element, mode, expirationTime) { expirationTime, key ); - case REACT_ASYNC_MODE_TYPE: + case REACT_CONCURRENT_MODE_TYPE: fiberTag = 10; mode |= 3; break; @@ -1902,6 +1913,9 @@ function createFiberFromElement(element, mode, expirationTime) { case REACT_FORWARD_REF_TYPE: fiberTag = 13; break a; + case REACT_PURE_TYPE: + fiberTag = 17; + break a; default: if ("function" === typeof type.then) { fiberTag = 4; @@ -2461,15 +2475,11 @@ function checkShouldComponentUpdate( newProps, oldState, newState, - nextLegacyContext + nextContext ) { workInProgress = workInProgress.stateNode; return "function" === typeof workInProgress.shouldComponentUpdate - ? workInProgress.shouldComponentUpdate( - newProps, - newState, - nextLegacyContext - ) + ? workInProgress.shouldComponentUpdate(newProps, newState, nextContext) : ctor.prototype && ctor.prototype.isPureReactComponent ? !shallowEqual(oldProps, newProps) || !shallowEqual(oldState, newState) : !0; @@ -2478,13 +2488,13 @@ function callComponentWillReceiveProps( workInProgress, instance, newProps, - nextLegacyContext + nextContext ) { workInProgress = instance.state; "function" === typeof instance.componentWillReceiveProps && - instance.componentWillReceiveProps(newProps, nextLegacyContext); + instance.componentWillReceiveProps(newProps, nextContext); "function" === typeof instance.UNSAFE_componentWillReceiveProps && - instance.UNSAFE_componentWillReceiveProps(newProps, nextLegacyContext); + instance.UNSAFE_componentWillReceiveProps(newProps, nextContext); instance.state !== workInProgress && classComponentUpdater.enqueueReplaceState(instance, instance.state, null); } @@ -2494,32 +2504,30 @@ function mountClassInstance( newProps, renderExpirationTime ) { - var instance = workInProgress.stateNode, - unmaskedContext = isContextProvider(ctor) - ? previousContext - : contextStackCursor.current; + var instance = workInProgress.stateNode; instance.props = newProps; instance.state = workInProgress.memoizedState; instance.refs = emptyRefsObject; - instance.context = getMaskedContext(workInProgress, unmaskedContext); - unmaskedContext = workInProgress.updateQueue; - null !== unmaskedContext && + var contextType = ctor.contextType; + "object" === typeof contextType && null !== contextType + ? (instance.context = contextType.unstable_read()) + : ((contextType = isContextProvider(ctor) + ? previousContext + : contextStackCursor.current), + (instance.context = getMaskedContext(workInProgress, contextType))); + contextType = workInProgress.updateQueue; + null !== contextType && (processUpdateQueue( workInProgress, - unmaskedContext, + contextType, newProps, instance, renderExpirationTime ), (instance.state = workInProgress.memoizedState)); - unmaskedContext = ctor.getDerivedStateFromProps; - "function" === typeof unmaskedContext && - (applyDerivedStateFromProps( - workInProgress, - ctor, - unmaskedContext, - newProps - ), + contextType = ctor.getDerivedStateFromProps; + "function" === typeof contextType && + (applyDerivedStateFromProps(workInProgress, ctor, contextType, newProps), (instance.state = workInProgress.memoizedState)); "function" === typeof ctor.getDerivedStateFromProps || "function" === typeof instance.getSnapshotBeforeUpdate || @@ -2532,11 +2540,11 @@ function mountClassInstance( instance.UNSAFE_componentWillMount(), ctor !== instance.state && classComponentUpdater.enqueueReplaceState(instance, instance.state, null), - (unmaskedContext = workInProgress.updateQueue), - null !== unmaskedContext && + (contextType = workInProgress.updateQueue), + null !== contextType && (processUpdateQueue( workInProgress, - unmaskedContext, + contextType, newProps, instance, renderExpirationTime @@ -2545,7 +2553,7 @@ function mountClassInstance( "function" === typeof instance.componentDidMount && (workInProgress.effectTag |= 4); } -var isArray$1 = Array.isArray; +var isArray = Array.isArray; function coerceRef(returnFiber, current$$1, element) { returnFiber = element.ref; if ( @@ -2559,7 +2567,7 @@ function coerceRef(returnFiber, current$$1, element) { element && (invariant( 2 === element.tag || 3 === element.tag, - "Stateless function components cannot have refs." + "Function components cannot have refs." ), (inst = element.stateNode)); invariant( @@ -2589,7 +2597,7 @@ function coerceRef(returnFiber, current$$1, element) { ); invariant( element._owner, - "Element ref was specified as a string (%s) but no owner was set. This could happen for one of the following reasons:\n1. You may be adding a ref to a functional component\n2. You may be adding a ref to a component that was not created inside a component's render method\n3. You have multiple copies of React loaded\nSee https://fb.me/react-refs-must-have-owner for more information.", + "Element ref was specified as a string (%s) but no owner was set. This could happen for one of the following reasons:\n1. You may be adding a ref to a function component\n2. You may be adding a ref to a component that was not created inside a component's render method\n3. You have multiple copies of React loaded\nSee https://fb.me/react-refs-must-have-owner for more information.", returnFiber ); } @@ -2773,7 +2781,7 @@ function ChildReconciler(shouldTrackSideEffects) { newChild ); } - if (isArray$1(newChild) || getIteratorFn(newChild)) + if (isArray(newChild) || getIteratorFn(newChild)) return ( (newChild = createFiberFromFragment( newChild, @@ -2813,7 +2821,7 @@ function ChildReconciler(shouldTrackSideEffects) { ? updatePortal(returnFiber, oldFiber, newChild, expirationTime) : null; } - if (isArray$1(newChild) || getIteratorFn(newChild)) + if (isArray(newChild) || getIteratorFn(newChild)) return null !== key ? null : updateFragment( @@ -2881,7 +2889,7 @@ function ChildReconciler(shouldTrackSideEffects) { ) ); } - if (isArray$1(newChild) || getIteratorFn(newChild)) + if (isArray(newChild) || getIteratorFn(newChild)) return ( (existingChildren = existingChildren.get(newIdx) || null), updateFragment( @@ -3220,7 +3228,7 @@ function ChildReconciler(shouldTrackSideEffects) { (returnFiber = currentFirstChild)), placeSingleChild(returnFiber) ); - if (isArray$1(newChild)) + if (isArray(newChild)) return reconcileChildrenArray( returnFiber, currentFirstChild, @@ -3381,6 +3389,36 @@ function updateForwardRef( workInProgress.memoizedProps = nextProps; return workInProgress.child; } +function updatePureComponent( + current$$1, + workInProgress, + Component, + nextProps, + updateExpirationTime, + renderExpirationTime +) { + var render = Component.render; + if ( + null !== current$$1 && + (0 === updateExpirationTime || + updateExpirationTime > renderExpirationTime) && + ((updateExpirationTime = current$$1.memoizedProps), + (Component = Component.compare), + (Component = null !== Component ? Component : shallowEqual), + Component(updateExpirationTime, nextProps)) + ) + return bailoutOnAlreadyFinishedWork( + current$$1, + workInProgress, + renderExpirationTime + ); + prepareToReadContext(workInProgress, renderExpirationTime); + render = render(nextProps); + workInProgress.effectTag |= 1; + reconcileChildren(current$$1, workInProgress, render, renderExpirationTime); + workInProgress.memoizedProps = nextProps; + return workInProgress.child; +} function markRef(current$$1, workInProgress) { var ref = workInProgress.ref; if ( @@ -3389,7 +3427,7 @@ function markRef(current$$1, workInProgress) { ) workInProgress.effectTag |= 128; } -function updateFunctionalComponent( +function updateFunctionComponent( current$$1, workInProgress, Component, @@ -3426,15 +3464,21 @@ function updateClassComponent( prepareToReadContext(workInProgress, renderExpirationTime); if (null === current$$1) if (null === workInProgress.stateNode) { - var unmaskedContext = isContextProvider(Component) - ? previousContext - : contextStackCursor.current, - contextTypes = Component.contextTypes, - isContextConsumer = null !== contextTypes && void 0 !== contextTypes; - contextTypes = isContextConsumer - ? getMaskedContext(workInProgress, unmaskedContext) - : emptyContextObject; - var instance = new Component(nextProps, contextTypes); + var isLegacyContextConsumer = !1, + unmaskedContext = emptyContextObject; + var context = Component.contextType; + "object" === typeof context && null !== context + ? (context = context.unstable_read()) + : ((unmaskedContext = isContextProvider(Component) + ? previousContext + : contextStackCursor.current), + (isLegacyContextConsumer = Component.contextTypes), + (context = (isLegacyContextConsumer = + null !== isLegacyContextConsumer && + void 0 !== isLegacyContextConsumer) + ? getMaskedContext(workInProgress, unmaskedContext) + : emptyContextObject)); + var instance = new Component(nextProps, context); workInProgress.memoizedState = null !== instance.state && void 0 !== instance.state ? instance.state @@ -3442,10 +3486,10 @@ function updateClassComponent( instance.updater = classComponentUpdater; workInProgress.stateNode = instance; instance._reactInternalFiber = workInProgress; - isContextConsumer && - ((isContextConsumer = workInProgress.stateNode), - (isContextConsumer.__reactInternalMemoizedUnmaskedChildContext = unmaskedContext), - (isContextConsumer.__reactInternalMemoizedMaskedChildContext = contextTypes)); + isLegacyContextConsumer && + ((isLegacyContextConsumer = workInProgress.stateNode), + (isLegacyContextConsumer.__reactInternalMemoizedUnmaskedChildContext = unmaskedContext), + (isLegacyContextConsumer.__reactInternalMemoizedMaskedChildContext = context)); mountClassInstance( workInProgress, Component, @@ -3455,13 +3499,16 @@ function updateClassComponent( nextProps = !0; } else { unmaskedContext = workInProgress.stateNode; - contextTypes = workInProgress.memoizedProps; - unmaskedContext.props = contextTypes; + isLegacyContextConsumer = workInProgress.memoizedProps; + unmaskedContext.props = isLegacyContextConsumer; var oldContext = unmaskedContext.context; - isContextConsumer = isContextProvider(Component) - ? previousContext - : contextStackCursor.current; - isContextConsumer = getMaskedContext(workInProgress, isContextConsumer); + context = Component.contextType; + "object" === typeof context && null !== context + ? (context = context.unstable_read()) + : ((context = isContextProvider(Component) + ? previousContext + : contextStackCursor.current), + (context = getMaskedContext(workInProgress, context))); var getDerivedStateFromProps = Component.getDerivedStateFromProps; (instance = "function" === typeof getDerivedStateFromProps || @@ -3469,12 +3516,12 @@ function updateClassComponent( ("function" !== typeof unmaskedContext.UNSAFE_componentWillReceiveProps && "function" !== typeof unmaskedContext.componentWillReceiveProps) || - ((contextTypes !== nextProps || oldContext !== isContextConsumer) && + ((isLegacyContextConsumer !== nextProps || oldContext !== context) && callComponentWillReceiveProps( workInProgress, unmaskedContext, nextProps, - isContextConsumer + context )); hasForceUpdate = !1; var oldState = workInProgress.memoizedState; @@ -3489,7 +3536,7 @@ function updateClassComponent( renderExpirationTime ), (oldContext = workInProgress.memoizedState)); - contextTypes !== nextProps || + isLegacyContextConsumer !== nextProps || oldState !== oldContext || didPerformWorkStackCursor.current || hasForceUpdate @@ -3501,16 +3548,16 @@ function updateClassComponent( nextProps ), (oldContext = workInProgress.memoizedState)), - (contextTypes = + (isLegacyContextConsumer = hasForceUpdate || checkShouldComponentUpdate( workInProgress, Component, - contextTypes, + isLegacyContextConsumer, nextProps, oldState, oldContext, - isContextConsumer + context )) ? (instance || ("function" !== @@ -3529,21 +3576,24 @@ function updateClassComponent( (workInProgress.memoizedState = oldContext)), (unmaskedContext.props = nextProps), (unmaskedContext.state = oldContext), - (unmaskedContext.context = isContextConsumer), - (nextProps = contextTypes)) + (unmaskedContext.context = context), + (nextProps = isLegacyContextConsumer)) : ("function" === typeof unmaskedContext.componentDidMount && (workInProgress.effectTag |= 4), (nextProps = !1)); } else (unmaskedContext = workInProgress.stateNode), - (contextTypes = workInProgress.memoizedProps), - (unmaskedContext.props = contextTypes), + (isLegacyContextConsumer = workInProgress.memoizedProps), + (unmaskedContext.props = isLegacyContextConsumer), (oldContext = unmaskedContext.context), - (isContextConsumer = isContextProvider(Component) - ? previousContext - : contextStackCursor.current), - (isContextConsumer = getMaskedContext(workInProgress, isContextConsumer)), + (context = Component.contextType), + "object" === typeof context && null !== context + ? (context = context.unstable_read()) + : ((context = isContextProvider(Component) + ? previousContext + : contextStackCursor.current), + (context = getMaskedContext(workInProgress, context))), (getDerivedStateFromProps = Component.getDerivedStateFromProps), (instance = "function" === typeof getDerivedStateFromProps || @@ -3551,12 +3601,12 @@ function updateClassComponent( ("function" !== typeof unmaskedContext.UNSAFE_componentWillReceiveProps && "function" !== typeof unmaskedContext.componentWillReceiveProps) || - ((contextTypes !== nextProps || oldContext !== isContextConsumer) && + ((isLegacyContextConsumer !== nextProps || oldContext !== context) && callComponentWillReceiveProps( workInProgress, unmaskedContext, nextProps, - isContextConsumer + context )), (hasForceUpdate = !1), (oldContext = workInProgress.memoizedState), @@ -3571,7 +3621,7 @@ function updateClassComponent( renderExpirationTime ), (oldState = workInProgress.memoizedState)), - contextTypes !== nextProps || + isLegacyContextConsumer !== nextProps || oldContext !== oldState || didPerformWorkStackCursor.current || hasForceUpdate @@ -3588,11 +3638,11 @@ function updateClassComponent( checkShouldComponentUpdate( workInProgress, Component, - contextTypes, + isLegacyContextConsumer, nextProps, oldContext, oldState, - isContextConsumer + context )) ? (instance || ("function" !== @@ -3602,39 +3652,39 @@ function updateClassComponent( unmaskedContext.componentWillUpdate( nextProps, oldState, - isContextConsumer + context ), "function" === typeof unmaskedContext.UNSAFE_componentWillUpdate && unmaskedContext.UNSAFE_componentWillUpdate( nextProps, oldState, - isContextConsumer + context )), "function" === typeof unmaskedContext.componentDidUpdate && (workInProgress.effectTag |= 4), "function" === typeof unmaskedContext.getSnapshotBeforeUpdate && (workInProgress.effectTag |= 256)) : ("function" !== typeof unmaskedContext.componentDidUpdate || - (contextTypes === current$$1.memoizedProps && + (isLegacyContextConsumer === current$$1.memoizedProps && oldContext === current$$1.memoizedState) || (workInProgress.effectTag |= 4), "function" !== typeof unmaskedContext.getSnapshotBeforeUpdate || - (contextTypes === current$$1.memoizedProps && + (isLegacyContextConsumer === current$$1.memoizedProps && oldContext === current$$1.memoizedState) || (workInProgress.effectTag |= 256), (workInProgress.memoizedProps = nextProps), (workInProgress.memoizedState = oldState)), (unmaskedContext.props = nextProps), (unmaskedContext.state = oldState), - (unmaskedContext.context = isContextConsumer), + (unmaskedContext.context = context), (nextProps = getDerivedStateFromProps)) : ("function" !== typeof unmaskedContext.componentDidUpdate || - (contextTypes === current$$1.memoizedProps && + (isLegacyContextConsumer === current$$1.memoizedProps && oldContext === current$$1.memoizedState) || (workInProgress.effectTag |= 4), "function" !== typeof unmaskedContext.getSnapshotBeforeUpdate || - (contextTypes === current$$1.memoizedProps && + (isLegacyContextConsumer === current$$1.memoizedProps && oldContext === current$$1.memoizedState) || (workInProgress.effectTag |= 256), (nextProps = !1)); @@ -3668,21 +3718,34 @@ function finishClassComponent( ); shouldUpdate = workInProgress.stateNode; ReactCurrentOwner$3.current = workInProgress; - if (didCaptureError) { + if ( + didCaptureError && + "function" !== typeof Component.getDerivedStateFromError + ) { var nextChildren = null; profilerStartTime = -1; } else nextChildren = shouldUpdate.render(); workInProgress.effectTag |= 1; - null !== current$$1 && - didCaptureError && - (reconcileChildren(current$$1, workInProgress, null, renderExpirationTime), - (workInProgress.child = null)); - reconcileChildren( - current$$1, - workInProgress, - nextChildren, - renderExpirationTime - ); + null !== current$$1 && didCaptureError + ? ((didCaptureError = nextChildren), + (workInProgress.child = reconcileChildFibers( + workInProgress, + current$$1.child, + null, + renderExpirationTime + )), + (workInProgress.child = reconcileChildFibers( + workInProgress, + null, + didCaptureError, + renderExpirationTime + ))) + : reconcileChildren( + current$$1, + workInProgress, + nextChildren, + renderExpirationTime + ); workInProgress.memoizedState = shouldUpdate.state; workInProgress.memoizedProps = shouldUpdate.props; hasContext && invalidateContextProvider(workInProgress, Component, !0); @@ -3710,122 +3773,6 @@ function resolveDefaultProps(Component, baseProps) { } return baseProps; } -function mountIndeterminateComponent( - current$$1, - workInProgress, - Component, - renderExpirationTime -) { - invariant( - null === current$$1, - "An indeterminate component should never have mounted. This error is likely caused by a bug in React. Please file an issue." - ); - var props = workInProgress.pendingProps; - if ( - "object" === typeof Component && - null !== Component && - "function" === typeof Component.then - ) { - Component = readLazyComponentType(Component); - var JSCompiler_inline_result = Component; - JSCompiler_inline_result = - "function" === typeof JSCompiler_inline_result - ? shouldConstruct(JSCompiler_inline_result) - ? 3 - : 1 - : void 0 !== JSCompiler_inline_result && - null !== JSCompiler_inline_result && - JSCompiler_inline_result.$$typeof - ? 14 - : 4; - JSCompiler_inline_result = workInProgress.tag = JSCompiler_inline_result; - var resolvedProps = resolveDefaultProps(Component, props); - switch (JSCompiler_inline_result) { - case 1: - return updateFunctionalComponent( - current$$1, - workInProgress, - Component, - resolvedProps, - renderExpirationTime - ); - case 3: - return updateClassComponent( - current$$1, - workInProgress, - Component, - resolvedProps, - renderExpirationTime - ); - case 14: - return updateForwardRef( - current$$1, - workInProgress, - Component, - resolvedProps, - renderExpirationTime - ); - default: - invariant( - !1, - "Element type is invalid. Received a promise that resolves to: %s. Promise elements must resolve to a class or function.", - Component - ); - } - } - JSCompiler_inline_result = getMaskedContext( - workInProgress, - contextStackCursor.current - ); - prepareToReadContext(workInProgress, renderExpirationTime); - JSCompiler_inline_result = Component(props, JSCompiler_inline_result); - workInProgress.effectTag |= 1; - if ( - "object" === typeof JSCompiler_inline_result && - null !== JSCompiler_inline_result && - "function" === typeof JSCompiler_inline_result.render && - void 0 === JSCompiler_inline_result.$$typeof - ) { - workInProgress.tag = 2; - isContextProvider(Component) - ? ((resolvedProps = !0), pushContextProvider(workInProgress)) - : (resolvedProps = !1); - workInProgress.memoizedState = - null !== JSCompiler_inline_result.state && - void 0 !== JSCompiler_inline_result.state - ? JSCompiler_inline_result.state - : null; - var getDerivedStateFromProps = Component.getDerivedStateFromProps; - "function" === typeof getDerivedStateFromProps && - applyDerivedStateFromProps( - workInProgress, - Component, - getDerivedStateFromProps, - props - ); - JSCompiler_inline_result.updater = classComponentUpdater; - workInProgress.stateNode = JSCompiler_inline_result; - JSCompiler_inline_result._reactInternalFiber = workInProgress; - mountClassInstance(workInProgress, Component, props, renderExpirationTime); - return finishClassComponent( - current$$1, - workInProgress, - Component, - !0, - resolvedProps, - renderExpirationTime - ); - } - workInProgress.tag = 0; - reconcileChildren( - current$$1, - workInProgress, - JSCompiler_inline_result, - renderExpirationTime - ); - workInProgress.memoizedProps = props; - return workInProgress.child; -} function bailoutOnAlreadyFinishedWork( current$$1, workInProgress, @@ -3868,6 +3815,8 @@ function bailoutOnAlreadyFinishedWork( function beginWork(current$$1, workInProgress, renderExpirationTime) { var updateExpirationTime = workInProgress.expirationTime; if ( + null !== current$$1 && + current$$1.memoizedProps === workInProgress.pendingProps && !didPerformWorkStackCursor.current && (0 === updateExpirationTime || updateExpirationTime > renderExpirationTime) ) { @@ -3907,14 +3856,129 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { workInProgress.expirationTime = 0; switch (workInProgress.tag) { case 4: - return mountIndeterminateComponent( - current$$1, - workInProgress, - workInProgress.type, - renderExpirationTime + var Component = workInProgress.type; + invariant( + null === current$$1, + "An indeterminate component should never have mounted. This error is likely caused by a bug in React. Please file an issue." ); + var props = workInProgress.pendingProps; + if ( + "object" === typeof Component && + null !== Component && + "function" === typeof Component.then + ) { + Component = readLazyComponentType(Component); + var resolvedTag = (workInProgress.tag = resolveLazyComponentTag( + workInProgress, + Component + )), + resolvedProps = resolveDefaultProps(Component, props), + child = void 0; + switch (resolvedTag) { + case 1: + child = updateFunctionComponent( + current$$1, + workInProgress, + Component, + resolvedProps, + renderExpirationTime + ); + break; + case 3: + child = updateClassComponent( + current$$1, + workInProgress, + Component, + resolvedProps, + renderExpirationTime + ); + break; + case 14: + child = updateForwardRef( + current$$1, + workInProgress, + Component, + resolvedProps, + renderExpirationTime + ); + break; + case 18: + child = updatePureComponent( + current$$1, + workInProgress, + Component, + resolvedProps, + updateExpirationTime, + renderExpirationTime + ); + break; + default: + invariant( + !1, + "Element type is invalid. Received a promise that resolves to: %s. Promise elements must resolve to a class or function.", + Component + ); + } + workInProgress.memoizedProps = props; + workInProgress = child; + } else + (updateExpirationTime = getMaskedContext( + workInProgress, + contextStackCursor.current + )), + prepareToReadContext(workInProgress, renderExpirationTime), + (updateExpirationTime = Component(props, updateExpirationTime)), + (workInProgress.effectTag |= 1), + "object" === typeof updateExpirationTime && + null !== updateExpirationTime && + "function" === typeof updateExpirationTime.render && + void 0 === updateExpirationTime.$$typeof + ? ((workInProgress.tag = 2), + isContextProvider(Component) + ? ((resolvedTag = !0), pushContextProvider(workInProgress)) + : (resolvedTag = !1), + (workInProgress.memoizedState = + null !== updateExpirationTime.state && + void 0 !== updateExpirationTime.state + ? updateExpirationTime.state + : null), + (resolvedProps = Component.getDerivedStateFromProps), + "function" === typeof resolvedProps && + applyDerivedStateFromProps( + workInProgress, + Component, + resolvedProps, + props + ), + (updateExpirationTime.updater = classComponentUpdater), + (workInProgress.stateNode = updateExpirationTime), + (updateExpirationTime._reactInternalFiber = workInProgress), + mountClassInstance( + workInProgress, + Component, + props, + renderExpirationTime + ), + (workInProgress = finishClassComponent( + current$$1, + workInProgress, + Component, + !0, + resolvedTag, + renderExpirationTime + ))) + : ((workInProgress.tag = 0), + reconcileChildren( + current$$1, + workInProgress, + updateExpirationTime, + renderExpirationTime + ), + (workInProgress.memoizedProps = props), + (workInProgress = workInProgress.child)); + return workInProgress; case 0: - return updateFunctionalComponent( + return updateFunctionComponent( current$$1, workInProgress, workInProgress.type, @@ -3922,17 +3986,19 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { renderExpirationTime ); case 1: - var _Component5 = workInProgress.type._reactResult; - updateExpirationTime = workInProgress.pendingProps; - current$$1 = updateFunctionalComponent( - current$$1, - workInProgress, - _Component5, - resolveDefaultProps(_Component5, updateExpirationTime), - renderExpirationTime + return ( + (props = workInProgress.type._reactResult), + (Component = workInProgress.pendingProps), + (current$$1 = updateFunctionComponent( + current$$1, + workInProgress, + props, + resolveDefaultProps(props, Component), + renderExpirationTime + )), + (workInProgress.memoizedProps = Component), + current$$1 ); - workInProgress.memoizedProps = updateExpirationTime; - return current$$1; case 2: return updateClassComponent( current$$1, @@ -3943,37 +4009,37 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { ); case 3: return ( - (_Component5 = workInProgress.type._reactResult), - (updateExpirationTime = workInProgress.pendingProps), + (props = workInProgress.type._reactResult), + (Component = workInProgress.pendingProps), (current$$1 = updateClassComponent( current$$1, workInProgress, - _Component5, - resolveDefaultProps(_Component5, updateExpirationTime), + props, + resolveDefaultProps(props, Component), renderExpirationTime )), - (workInProgress.memoizedProps = updateExpirationTime), + (workInProgress.memoizedProps = Component), current$$1 ); case 5: return ( pushHostRootContext(workInProgress), - (updateExpirationTime = workInProgress.updateQueue), + (Component = workInProgress.updateQueue), invariant( - null !== updateExpirationTime, + null !== Component, "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." ), - (_Component5 = workInProgress.memoizedState), - (_Component5 = null !== _Component5 ? _Component5.element : null), + (props = workInProgress.memoizedState), + (props = null !== props ? props.element : null), processUpdateQueue( workInProgress, - updateExpirationTime, + Component, workInProgress.pendingProps, null, renderExpirationTime ), - (updateExpirationTime = workInProgress.memoizedState.element), - updateExpirationTime === _Component5 + (Component = workInProgress.memoizedState.element), + Component === props ? (workInProgress = bailoutOnAlreadyFinishedWork( current$$1, workInProgress, @@ -3982,7 +4048,7 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { : (reconcileChildren( current$$1, workInProgress, - updateExpirationTime, + Component, renderExpirationTime ), (workInProgress = workInProgress.child)), @@ -3992,16 +4058,16 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { return ( pushHostContext(workInProgress), null === current$$1 && tryToClaimNextHydratableInstance(workInProgress), - (updateExpirationTime = workInProgress.pendingProps), - (_Component5 = updateExpirationTime.children), + (Component = workInProgress.pendingProps), + (props = Component.children), markRef(current$$1, workInProgress), reconcileChildren( current$$1, workInProgress, - _Component5, + props, renderExpirationTime ), - (workInProgress.memoizedProps = updateExpirationTime), + (workInProgress.memoizedProps = Component), (workInProgress = workInProgress.child), workInProgress ); @@ -4019,21 +4085,21 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { workInProgress, workInProgress.stateNode.containerInfo ), - (updateExpirationTime = workInProgress.pendingProps), + (Component = workInProgress.pendingProps), null === current$$1 ? (workInProgress.child = reconcileChildFibers( workInProgress, null, - updateExpirationTime, + Component, renderExpirationTime )) : reconcileChildren( current$$1, workInProgress, - updateExpirationTime, + Component, renderExpirationTime ), - (workInProgress.memoizedProps = updateExpirationTime), + (workInProgress.memoizedProps = Component), workInProgress.child ); case 13: @@ -4046,80 +4112,83 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { ); case 14: return ( - (_Component5 = workInProgress.type._reactResult), - (updateExpirationTime = workInProgress.pendingProps), + (props = workInProgress.type._reactResult), + (Component = workInProgress.pendingProps), (current$$1 = updateForwardRef( current$$1, workInProgress, - _Component5, - resolveDefaultProps(_Component5, updateExpirationTime), + props, + resolveDefaultProps(props, Component), renderExpirationTime )), - (workInProgress.memoizedProps = updateExpirationTime), + (workInProgress.memoizedProps = Component), current$$1 ); case 9: return ( - (updateExpirationTime = workInProgress.pendingProps), + (Component = workInProgress.pendingProps), reconcileChildren( current$$1, workInProgress, - updateExpirationTime, + Component, renderExpirationTime ), - (workInProgress.memoizedProps = updateExpirationTime), + (workInProgress.memoizedProps = Component), workInProgress.child ); case 10: return ( - (updateExpirationTime = workInProgress.pendingProps.children), + (Component = workInProgress.pendingProps.children), reconcileChildren( current$$1, workInProgress, - updateExpirationTime, + Component, renderExpirationTime ), - (workInProgress.memoizedProps = updateExpirationTime), + (workInProgress.memoizedProps = Component), workInProgress.child ); case 15: return ( (workInProgress.effectTag |= 4), - (updateExpirationTime = workInProgress.pendingProps), + (Component = workInProgress.pendingProps), reconcileChildren( current$$1, workInProgress, - updateExpirationTime.children, + Component.children, renderExpirationTime ), - (workInProgress.memoizedProps = updateExpirationTime), + (workInProgress.memoizedProps = Component), workInProgress.child ); case 12: a: { - updateExpirationTime = workInProgress.type._context; - _Component5 = workInProgress.pendingProps; - var oldProps = workInProgress.memoizedProps, - newValue = _Component5.value; - workInProgress.memoizedProps = _Component5; - pushProvider(workInProgress, newValue); - if (null !== oldProps) { - var oldValue = oldProps.value; - newValue = - (oldValue === newValue && - (0 !== oldValue || 1 / oldValue === 1 / newValue)) || - (oldValue !== oldValue && newValue !== newValue) - ? 0 - : ("function" === - typeof updateExpirationTime._calculateChangedBits - ? updateExpirationTime._calculateChangedBits( - oldValue, - newValue - ) - : 1073741823) | 0; - if (0 === newValue) { + Component = workInProgress.type._context; + props = workInProgress.pendingProps; + resolvedTag = workInProgress.memoizedProps; + updateExpirationTime = props.value; + workInProgress.memoizedProps = props; + pushProvider(workInProgress, updateExpirationTime); + if (null !== resolvedTag) + if ( + ((resolvedProps = resolvedTag.value), + (updateExpirationTime = + (resolvedProps === updateExpirationTime && + (0 !== resolvedProps || + 1 / resolvedProps === 1 / updateExpirationTime)) || + (resolvedProps !== resolvedProps && + updateExpirationTime !== updateExpirationTime) + ? 0 + : ("function" === typeof Component._calculateChangedBits + ? Component._calculateChangedBits( + resolvedProps, + updateExpirationTime + ) + : 1073741823) | 0), + 0 === updateExpirationTime) + ) { if ( - oldProps.children === _Component5.children && + resolvedTag.children === props.children && !didPerformWorkStackCursor.current ) { workInProgress = bailoutOnAlreadyFinishedWork( @@ -4131,87 +4200,85 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { } } else for ( - oldProps = workInProgress.child, - null !== oldProps && (oldProps.return = workInProgress); - null !== oldProps; + resolvedTag = workInProgress.child, + null !== resolvedTag && (resolvedTag.return = workInProgress); + null !== resolvedTag; ) { - oldValue = oldProps.firstContextDependency; - if (null !== oldValue) { + resolvedProps = resolvedTag.firstContextDependency; + if (null !== resolvedProps) { do { if ( - oldValue.context === updateExpirationTime && - 0 !== (oldValue.observedBits & newValue) + resolvedProps.context === Component && + 0 !== (resolvedProps.observedBits & updateExpirationTime) ) { - if (2 === oldProps.tag || 3 === oldProps.tag) { - var nextFiber = createUpdate(renderExpirationTime); - nextFiber.tag = 2; - enqueueUpdate(oldProps, nextFiber); - } + if (2 === resolvedTag.tag || 3 === resolvedTag.tag) + (child = createUpdate(renderExpirationTime)), + (child.tag = 2), + enqueueUpdate(resolvedTag, child); if ( - 0 === oldProps.expirationTime || - oldProps.expirationTime > renderExpirationTime + 0 === resolvedTag.expirationTime || + resolvedTag.expirationTime > renderExpirationTime ) - oldProps.expirationTime = renderExpirationTime; - nextFiber = oldProps.alternate; - null !== nextFiber && - (0 === nextFiber.expirationTime || - nextFiber.expirationTime > renderExpirationTime) && - (nextFiber.expirationTime = renderExpirationTime); - for (var node = oldProps.return; null !== node; ) { - nextFiber = node.alternate; + resolvedTag.expirationTime = renderExpirationTime; + child = resolvedTag.alternate; + null !== child && + (0 === child.expirationTime || + child.expirationTime > renderExpirationTime) && + (child.expirationTime = renderExpirationTime); + for (var node = resolvedTag.return; null !== node; ) { + child = node.alternate; if ( 0 === node.childExpirationTime || node.childExpirationTime > renderExpirationTime ) (node.childExpirationTime = renderExpirationTime), - null !== nextFiber && - (0 === nextFiber.childExpirationTime || - nextFiber.childExpirationTime > + null !== child && + (0 === child.childExpirationTime || + child.childExpirationTime > renderExpirationTime) && - (nextFiber.childExpirationTime = renderExpirationTime); + (child.childExpirationTime = renderExpirationTime); else if ( - null !== nextFiber && - (0 === nextFiber.childExpirationTime || - nextFiber.childExpirationTime > renderExpirationTime) + null !== child && + (0 === child.childExpirationTime || + child.childExpirationTime > renderExpirationTime) ) - nextFiber.childExpirationTime = renderExpirationTime; + child.childExpirationTime = renderExpirationTime; else break; node = node.return; } } - nextFiber = oldProps.child; - oldValue = oldValue.next; - } while (null !== oldValue); + child = resolvedTag.child; + resolvedProps = resolvedProps.next; + } while (null !== resolvedProps); } else - nextFiber = - 12 === oldProps.tag - ? oldProps.type === workInProgress.type + child = + 12 === resolvedTag.tag + ? resolvedTag.type === workInProgress.type ? null - : oldProps.child - : oldProps.child; - if (null !== nextFiber) nextFiber.return = oldProps; + : resolvedTag.child + : resolvedTag.child; + if (null !== child) child.return = resolvedTag; else - for (nextFiber = oldProps; null !== nextFiber; ) { - if (nextFiber === workInProgress) { - nextFiber = null; + for (child = resolvedTag; null !== child; ) { + if (child === workInProgress) { + child = null; break; } - oldProps = nextFiber.sibling; - if (null !== oldProps) { - oldProps.return = nextFiber.return; - nextFiber = oldProps; + resolvedTag = child.sibling; + if (null !== resolvedTag) { + resolvedTag.return = child.return; + child = resolvedTag; break; } - nextFiber = nextFiber.return; + child = child.return; } - oldProps = nextFiber; + resolvedTag = child; } - } reconcileChildren( current$$1, workInProgress, - _Component5.children, + props.children, renderExpirationTime ); workInProgress = workInProgress.child; @@ -4219,25 +4286,49 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { return workInProgress; case 11: return ( - (newValue = workInProgress.type), - (updateExpirationTime = workInProgress.pendingProps), - (_Component5 = updateExpirationTime.children), + (updateExpirationTime = workInProgress.type), + (Component = workInProgress.pendingProps), + (props = Component.children), prepareToReadContext(workInProgress, renderExpirationTime), - (newValue = readContext( - newValue, - updateExpirationTime.unstable_observedBits + (updateExpirationTime = readContext( + updateExpirationTime, + Component.unstable_observedBits )), - (_Component5 = _Component5(newValue)), + (props = props(updateExpirationTime)), (workInProgress.effectTag |= 1), reconcileChildren( current$$1, workInProgress, - _Component5, + props, renderExpirationTime ), - (workInProgress.memoizedProps = updateExpirationTime), + (workInProgress.memoizedProps = Component), workInProgress.child ); + case 17: + return updatePureComponent( + current$$1, + workInProgress, + workInProgress.type, + workInProgress.pendingProps, + updateExpirationTime, + renderExpirationTime + ); + case 18: + return ( + (props = workInProgress.type._reactResult), + (Component = workInProgress.pendingProps), + (current$$1 = updatePureComponent( + current$$1, + workInProgress, + props, + resolveDefaultProps(props, Component), + updateExpirationTime, + renderExpirationTime + )), + (workInProgress.memoizedProps = Component), + current$$1 + ); default: invariant( !1, @@ -4640,13 +4731,21 @@ function createRootErrorUpdate(fiber, errorInfo, expirationTime) { function createClassErrorUpdate(fiber, errorInfo, expirationTime) { expirationTime = createUpdate(expirationTime); expirationTime.tag = 3; + var getDerivedStateFromError = fiber.type.getDerivedStateFromError; + if ("function" === typeof getDerivedStateFromError) { + var error$jscomp$0 = errorInfo.value; + expirationTime.payload = function() { + return getDerivedStateFromError(error$jscomp$0); + }; + } var inst = fiber.stateNode; null !== inst && "function" === typeof inst.componentDidCatch && (expirationTime.callback = function() { - null === legacyErrorBoundariesThatAlreadyFailed - ? (legacyErrorBoundariesThatAlreadyFailed = new Set([this])) - : legacyErrorBoundariesThatAlreadyFailed.add(this); + "function" !== typeof getDerivedStateFromError && + (null === legacyErrorBoundariesThatAlreadyFailed + ? (legacyErrorBoundariesThatAlreadyFailed = new Set([this])) + : legacyErrorBoundariesThatAlreadyFailed.add(this)); var error = errorInfo.value, stack = errorInfo.stack; logError(fiber, errorInfo); @@ -4682,14 +4781,16 @@ function throwException( return; case 2: case 3: + returnFiber = value; + sourceFiber = root.type; + var instance = root.stateNode; if ( - ((returnFiber = value), - (sourceFiber = root.stateNode), 0 === (root.effectTag & 64) && - null !== sourceFiber && - "function" === typeof sourceFiber.componentDidCatch && - (null === legacyErrorBoundariesThatAlreadyFailed || - !legacyErrorBoundariesThatAlreadyFailed.has(sourceFiber))) + ("function" === typeof sourceFiber.getDerivedStateFromError || + (null !== instance && + "function" === typeof instance.componentDidCatch && + (null === legacyErrorBoundariesThatAlreadyFailed || + !legacyErrorBoundariesThatAlreadyFailed.has(instance)))) ) { root.effectTag |= 1024; root.expirationTime = renderExpirationTime; @@ -4757,9 +4858,9 @@ function unwindWork(workInProgress) { var Dispatcher = { readContext: readContext }, ReactCurrentOwner$2 = ReactSharedInternals.ReactCurrentOwner; invariant( - null != tracking.__interactionsRef && - null != tracking.__interactionsRef.current, - "It is not supported to run the profiling version of a renderer (for example, `react-dom/profiling`) without also replacing the `schedule/tracking` module with `schedule/tracking-profiling`. Your bundler might have a setting for aliasing both modules. Learn more at http://fb.me/react-profiling" + null != tracing.__interactionsRef && + null != tracing.__interactionsRef.current, + "It is not supported to run the profiling version of a renderer (for example, `react-dom/profiling`) without also replacing the `schedule/tracing` module with `schedule/tracing-profiling`. Your bundler might have a setting for aliasing both modules. Learn more at http://fb.me/react-profiling" ); var isWorking = !1, nextUnitOfWork = null, @@ -4768,8 +4869,7 @@ var isWorking = !1, nextRenderDidError = !1, nextEffect = null, isCommitting$1 = !1, - legacyErrorBoundariesThatAlreadyFailed = null, - suspenseDidTimeout = !1; + legacyErrorBoundariesThatAlreadyFailed = null; function resetStack() { if (null !== nextUnitOfWork) for ( @@ -5013,20 +5113,8 @@ function commitRoot(root, finishedWork) { : updateExpirationTimeBeforeCommit ); updateExpirationTimeBeforeCommit = null; - var committedInteractions = []; - updateExpirationTimeBeforeCommit = tracking.__interactionsRef.current; - tracking.__interactionsRef.current = root.memoizedInteractions; - root.pendingInteractionMap.forEach(function( - scheduledInteractions, - scheduledExpirationTime - ) { - scheduledExpirationTime <= committedExpirationTime && - (committedInteractions.push.apply( - committedInteractions, - Array.from(scheduledInteractions) - ), - root.pendingInteractionMap.delete(scheduledExpirationTime)); - }); + updateExpirationTimeBeforeCommit = tracing.__interactionsRef.current; + tracing.__interactionsRef.current = root.memoizedInteractions; ReactCurrentOwner$2.current = null; childExpirationTimeBeforeCommit = void 0; 1 < finishedWork.effectTag @@ -5090,18 +5178,19 @@ function commitRoot(root, finishedWork) { onCommitFiberRoot(finishedWork.stateNode); childExpirationTimeBeforeCommit = finishedWork.expirationTime; finishedWork = finishedWork.childExpirationTime; - finishedWork = + var earliestRemainingTimeAfterCommit = 0 === childExpirationTimeBeforeCommit || (0 !== finishedWork && finishedWork < childExpirationTimeBeforeCommit) ? finishedWork : childExpirationTimeBeforeCommit; - 0 === finishedWork && (legacyErrorBoundariesThatAlreadyFailed = null); - onCommit(root, finishedWork); - tracking.__interactionsRef.current = updateExpirationTimeBeforeCommit; + 0 === earliestRemainingTimeAfterCommit && + (legacyErrorBoundariesThatAlreadyFailed = null); + onCommit(root, earliestRemainingTimeAfterCommit); + tracing.__interactionsRef.current = updateExpirationTimeBeforeCommit; var subscriber = void 0; try { if ( - ((subscriber = tracking.__subscriberRef.current), + ((subscriber = tracing.__subscriberRef.current), null !== subscriber && 0 < root.memoizedInteractions.size) ) subscriber.onWorkStopped( @@ -5111,17 +5200,27 @@ function commitRoot(root, finishedWork) { } catch (error) { hasUnhandledError || ((hasUnhandledError = !0), (unhandledError = error)); } finally { - suspenseDidTimeout || - committedInteractions.forEach(function(interaction) { - interaction.__count--; - if (null !== subscriber && 0 === interaction.__count) - try { - subscriber.onInteractionScheduledWorkCompleted(interaction); - } catch (error) { - hasUnhandledError || - ((hasUnhandledError = !0), (unhandledError = error)); - } - }); + var pendingInteractionMap = root.pendingInteractionMap; + pendingInteractionMap.forEach(function( + scheduledInteractions, + scheduledExpirationTime + ) { + if ( + 0 === earliestRemainingTimeAfterCommit || + scheduledExpirationTime < earliestRemainingTimeAfterCommit + ) + pendingInteractionMap.delete(scheduledExpirationTime), + scheduledInteractions.forEach(function(interaction) { + interaction.__count--; + if (null !== subscriber && 0 === interaction.__count) + try { + subscriber.onInteractionScheduledWorkCompleted(interaction); + } catch (error) { + hasUnhandledError || + ((hasUnhandledError = !0), (unhandledError = error)); + } + }); + }); } } function completeUnitOfWork(workInProgress) { @@ -5290,6 +5389,9 @@ function completeUnitOfWork(workInProgress) { break; case 11: break; + case 17: + case 18: + break; case 4: invariant( !1, @@ -5304,60 +5406,48 @@ function completeUnitOfWork(workInProgress) { nextUnitOfWork = null; workInProgress.mode & 4 && stopProfilerTimerIfRunningAndRecordDelta(workInProgress, !1); - current$$1 = nextUnitOfWork; - fiber = workInProgress; + current$$1 = workInProgress; if ( 1073741823 === nextRenderExpirationTime || - 1073741823 !== fiber.childExpirationTime + 1073741823 !== current$$1.childExpirationTime ) { - rootContainerInstance = 0; - if (fiber.mode & 4) { - type = fiber.actualDuration; - current = fiber.selfBaseDuration; - viewConfig = - null === fiber.alternate || fiber.child !== fiber.alternate.child; - for ( - internalInstanceHandle = fiber.child; - null !== internalInstanceHandle; - - ) { - tag = internalInstanceHandle.expirationTime; - updatePayload = internalInstanceHandle.childExpirationTime; + fiber = 0; + if (current$$1.mode & 4) { + rootContainerInstance = current$$1.actualDuration; + type = current$$1.selfBaseDuration; + current = + null === current$$1.alternate || + current$$1.child !== current$$1.alternate.child; + for (viewConfig = current$$1.child; null !== viewConfig; ) { + internalInstanceHandle = viewConfig.expirationTime; + tag = viewConfig.childExpirationTime; if ( - 0 === rootContainerInstance || - (0 !== tag && tag < rootContainerInstance) + 0 === fiber || + (0 !== internalInstanceHandle && internalInstanceHandle < fiber) ) - rootContainerInstance = tag; - if ( - 0 === rootContainerInstance || - (0 !== updatePayload && updatePayload < rootContainerInstance) - ) - rootContainerInstance = updatePayload; - viewConfig && (type += internalInstanceHandle.actualDuration); - current += internalInstanceHandle.treeBaseDuration; - internalInstanceHandle = internalInstanceHandle.sibling; + fiber = internalInstanceHandle; + if (0 === fiber || (0 !== tag && tag < fiber)) fiber = tag; + current && (rootContainerInstance += viewConfig.actualDuration); + type += viewConfig.treeBaseDuration; + viewConfig = viewConfig.sibling; } - fiber.actualDuration = type; - fiber.treeBaseDuration = current; + current$$1.actualDuration = rootContainerInstance; + current$$1.treeBaseDuration = type; } else - for (type = fiber.child; null !== type; ) { - current = type.expirationTime; - viewConfig = type.childExpirationTime; - if ( - 0 === rootContainerInstance || - (0 !== current && current < rootContainerInstance) - ) - rootContainerInstance = current; - if ( - 0 === rootContainerInstance || - (0 !== viewConfig && viewConfig < rootContainerInstance) - ) - rootContainerInstance = viewConfig; - type = type.sibling; + for ( + rootContainerInstance = current$$1.child; + null !== rootContainerInstance; + + ) { + type = rootContainerInstance.expirationTime; + current = rootContainerInstance.childExpirationTime; + if (0 === fiber || (0 !== type && type < fiber)) fiber = type; + if (0 === fiber || (0 !== current && current < fiber)) + fiber = current; + rootContainerInstance = rootContainerInstance.sibling; } - fiber.childExpirationTime = rootContainerInstance; + current$$1.childExpirationTime = fiber; } - if (null !== current$$1) return current$$1; null !== returnFiber && 0 === (returnFiber.effectTag & 512) && (null === returnFiber.firstEffect && @@ -5416,10 +5506,7 @@ function renderRoot(root, isYieldy, isExpired) { ); isWorking = !0; ReactCurrentOwner$2.currentDispatcher = Dispatcher; - var expirationTime = root.nextExpirationTimeToWorkOn, - prevInteractions = null; - prevInteractions = tracking.__interactionsRef.current; - tracking.__interactionsRef.current = root.memoizedInteractions; + var expirationTime = root.nextExpirationTimeToWorkOn; if ( expirationTime !== nextRenderExpirationTime || root !== nextRoot || @@ -5446,7 +5533,7 @@ function renderRoot(root, isYieldy, isExpired) { }); root.memoizedInteractions = interactions; if (0 < interactions.size) { - var subscriber = tracking.__subscriberRef.current; + var subscriber = tracing.__subscriberRef.current; if (null !== subscriber) { var threadID = 1e3 * expirationTime + root.interactionThreadID; try { @@ -5458,7 +5545,10 @@ function renderRoot(root, isYieldy, isExpired) { } } } - subscriber = !1; + subscriber = null; + subscriber = tracing.__interactionsRef.current; + tracing.__interactionsRef.current = root.memoizedInteractions; + threadID = !1; do { try { if (isYieldy) @@ -5469,35 +5559,34 @@ function renderRoot(root, isYieldy, isExpired) { nextUnitOfWork = performUnitOfWork(nextUnitOfWork); } catch (thrownValue) { if (null === nextUnitOfWork) - (subscriber = !0), onUncaughtError(thrownValue); + (threadID = !0), onUncaughtError(thrownValue); else { invariant( null !== nextUnitOfWork, "Failed to replay rendering after an error. This is likely caused by a bug in React. Please file an issue with a reproducing case to help us find it." ); - threadID = nextUnitOfWork; - var returnFiber = threadID.return; - if (null === returnFiber) - (subscriber = !0), onUncaughtError(thrownValue); + var sourceFiber = nextUnitOfWork, + returnFiber = sourceFiber.return; + if (null === returnFiber) (threadID = !0), onUncaughtError(thrownValue); else { throwException( root, returnFiber, - threadID, + sourceFiber, thrownValue, nextRenderExpirationTime ); - nextUnitOfWork = completeUnitOfWork(threadID); + nextUnitOfWork = completeUnitOfWork(sourceFiber); continue; } } } break; } while (1); - tracking.__interactionsRef.current = prevInteractions; + tracing.__interactionsRef.current = subscriber; isWorking = !1; lastContextWithAllBitsObserved = lastContextDependency = currentlyRenderingFiber = ReactCurrentOwner$2.currentDispatcher = null; - if (subscriber) (nextRoot = null), (root.finishedWork = null); + if (threadID) (nextRoot = null), (root.finishedWork = null); else if (null !== nextUnitOfWork) root.finishedWork = null; else { isYieldy = root.current.alternate; @@ -5515,8 +5604,8 @@ function renderRoot(root, isYieldy, isExpired) { if (!root.didError && !isExpired) { root.didError = !0; isExpired = root.nextExpirationTimeToWorkOn = expirationTime; - prevInteractions = root.expirationTime = 1; - onSuspend(root, isYieldy, isExpired, prevInteractions, -1); + subscriber = root.expirationTime = 1; + onSuspend(root, isYieldy, isExpired, subscriber, -1); return; } } @@ -5541,7 +5630,7 @@ function captureCommitPhaseError(fiber, error) { var instance = JSCompiler_inline_result.stateNode; if ( "function" === - typeof JSCompiler_inline_result.type.getDerivedStateFromCatch || + typeof JSCompiler_inline_result.type.getDerivedStateFromError || ("function" === typeof instance.componentDidCatch && (null === legacyErrorBoundariesThatAlreadyFailed || !legacyErrorBoundariesThatAlreadyFailed.has(instance))) @@ -5589,102 +5678,96 @@ function computeExpirationForFiber(currentTime, fiber) { (currentTime += 1)) : (currentTime = 1); isBatchingInteractiveUpdates && - (0 === lowestPriorityPendingInteractiveExpirationTime || - currentTime > lowestPriorityPendingInteractiveExpirationTime) && + currentTime > lowestPriorityPendingInteractiveExpirationTime && (lowestPriorityPendingInteractiveExpirationTime = currentTime); return currentTime; } -function storeInteractionsForExpirationTime( - root, - expirationTime, - updateInteractionCounts -) { - var interactions = tracking.__interactionsRef.current; - if (0 < interactions.size) { - var pendingInteractions = root.pendingInteractionMap.get(expirationTime); +function scheduleWorkToRoot(fiber, expirationTime) { + if (0 === fiber.expirationTime || fiber.expirationTime > expirationTime) + fiber.expirationTime = expirationTime; + var alternate = fiber.alternate; + null !== alternate && + (0 === alternate.expirationTime || + alternate.expirationTime > expirationTime) && + (alternate.expirationTime = expirationTime); + var node = fiber.return, + root = null; + if (null === node && 5 === fiber.tag) root = fiber.stateNode; + else + for (; null !== node; ) { + alternate = node.alternate; + if ( + 0 === node.childExpirationTime || + node.childExpirationTime > expirationTime + ) + node.childExpirationTime = expirationTime; + null !== alternate && + (0 === alternate.childExpirationTime || + alternate.childExpirationTime > expirationTime) && + (alternate.childExpirationTime = expirationTime); + if (null === node.return && 5 === node.tag) { + root = node.stateNode; + break; + } + node = node.return; + } + if (null === root) return null; + fiber = tracing.__interactionsRef.current; + if (0 < fiber.size) { + alternate = root.pendingInteractionMap; + var pendingInteractions = alternate.get(expirationTime); null != pendingInteractions - ? interactions.forEach(function(interaction) { - updateInteractionCounts && - !pendingInteractions.has(interaction) && - interaction.__count++; + ? fiber.forEach(function(interaction) { + pendingInteractions.has(interaction) || interaction.__count++; pendingInteractions.add(interaction); }) - : (root.pendingInteractionMap.set(expirationTime, new Set(interactions)), - updateInteractionCounts && - interactions.forEach(function(interaction) { - interaction.__count++; - })); - var subscriber = tracking.__subscriberRef.current; - if (null !== subscriber) - subscriber.onWorkScheduled( - interactions, + : (alternate.set(expirationTime, new Set(fiber)), + fiber.forEach(function(interaction) { + interaction.__count++; + })); + alternate = tracing.__subscriberRef.current; + if (null !== alternate) + alternate.onWorkScheduled( + fiber, 1e3 * expirationTime + root.interactionThreadID ); } + return root; } function scheduleWork(fiber, expirationTime) { - a: { - if (0 === fiber.expirationTime || fiber.expirationTime > expirationTime) - fiber.expirationTime = expirationTime; - var alternate = fiber.alternate; - null !== alternate && - (0 === alternate.expirationTime || - alternate.expirationTime > expirationTime) && - (alternate.expirationTime = expirationTime); - var node = fiber.return; - if (null === node && 5 === fiber.tag) fiber = fiber.stateNode; - else { - for (; null !== node; ) { - alternate = node.alternate; - if ( - 0 === node.childExpirationTime || - node.childExpirationTime > expirationTime - ) - node.childExpirationTime = expirationTime; - null !== alternate && - (0 === alternate.childExpirationTime || - alternate.childExpirationTime > expirationTime) && - (alternate.childExpirationTime = expirationTime); - if (null === node.return && 5 === node.tag) { - fiber = node.stateNode; - break a; - } - node = node.return; - } - fiber = null; - } - } + fiber = scheduleWorkToRoot(fiber, expirationTime); if (null !== fiber) { - storeInteractionsForExpirationTime(fiber, expirationTime, !0); !isWorking && 0 !== nextRenderExpirationTime && expirationTime < nextRenderExpirationTime && resetStack(); markPendingPriorityLevel(fiber, expirationTime); if (!isWorking || isCommitting$1 || nextRoot !== fiber) { - expirationTime = fiber; - fiber = fiber.expirationTime; - if (null === expirationTime.nextScheduledRoot) - (expirationTime.expirationTime = fiber), + expirationTime = fiber.expirationTime; + if (null === fiber.nextScheduledRoot) + (fiber.expirationTime = expirationTime), null === lastScheduledRoot - ? ((firstScheduledRoot = lastScheduledRoot = expirationTime), - (expirationTime.nextScheduledRoot = expirationTime)) - : ((lastScheduledRoot = lastScheduledRoot.nextScheduledRoot = expirationTime), + ? ((firstScheduledRoot = lastScheduledRoot = fiber), + (fiber.nextScheduledRoot = fiber)) + : ((lastScheduledRoot = lastScheduledRoot.nextScheduledRoot = fiber), (lastScheduledRoot.nextScheduledRoot = firstScheduledRoot)); - else if ( - ((alternate = expirationTime.expirationTime), - 0 === alternate || fiber < alternate) - ) - expirationTime.expirationTime = fiber; + else { + var remainingExpirationTime = fiber.expirationTime; + if ( + 0 === remainingExpirationTime || + expirationTime < remainingExpirationTime + ) + fiber.expirationTime = expirationTime; + } isRendering || (isBatchingUpdates ? isUnbatchingUpdates && - ((nextFlushedRoot = expirationTime), + ((nextFlushedRoot = fiber), (nextFlushedExpirationTime = 1), - performWorkOnRoot(expirationTime, 1, !0)) - : 1 === fiber + performWorkOnRoot(fiber, 1, !0)) + : 1 === expirationTime ? performWork(1, null) - : scheduleCallbackWithExpirationTime(expirationTime, fiber)); + : scheduleCallbackWithExpirationTime(fiber, expirationTime)); } nestedUpdateCount > NESTED_UPDATE_LIMIT && ((nestedUpdateCount = 0), @@ -6197,7 +6280,7 @@ var roots = new Map(), expirationTime: 0, firstBatch: null, nextScheduledRoot: null, - interactionThreadID: tracking.unstable_getThreadID(), + interactionThreadID: tracing.unstable_getThreadID(), memoizedInteractions: new Set(), pendingInteractionMap: new Map() }; @@ -6314,7 +6397,7 @@ var roots = new Map(), findFiberByHostInstance: getInstanceFromTag, getInspectorDataForViewTag: getInspectorDataForViewTag, bundleType: 0, - version: "16.5.0", + version: "16.5.2", rendererPackageName: "react-native-renderer" }); var ReactNativeRenderer$2 = { default: ReactNativeRenderer }, diff --git a/Libraries/Renderer/shims/ReactTypes.js b/Libraries/Renderer/shims/ReactTypes.js index 4beed2224b314b..20f76eef30f8c2 100644 --- a/Libraries/Renderer/shims/ReactTypes.js +++ b/Libraries/Renderer/shims/ReactTypes.js @@ -7,7 +7,6 @@ * @flow */ -/* eslint-disable no-use-before-define */ export type ReactNode = | React$Element | ReactPortal @@ -15,7 +14,6 @@ export type ReactNode = | ReactFragment | ReactProvider | ReactConsumer; -/* eslint-enable no-use-before-define */ export type ReactEmpty = null | void | boolean; diff --git a/package.json b/package.json index f7ba7ba1d63bf6..594327030e490f 100644 --- a/package.json +++ b/package.json @@ -147,7 +147,7 @@ "react-native": "local-cli/wrong-react-native.js" }, "peerDependencies": { - "react": "16.5.0" + "react": "16.6.0-alpha.400d197" }, "dependencies": { "@babel/runtime": "^7.0.0", @@ -223,9 +223,9 @@ "jest": "23.4.1", "jest-junit": "5.1.0", "prettier": "1.13.6", - "react": "16.5.0", + "react": "16.6.0-alpha.400d197", "react-native-dummy": "0.1.0", - "react-test-renderer": "16.5.0", + "react-test-renderer": "16.6.0-alpha.400d197", "shelljs": "^0.7.8", "sinon": "^2.2.0" },