diff --git a/Libraries/Renderer/REVISION b/Libraries/Renderer/REVISION index 4d4a836a18ad74..3455723424e22f 100644 --- a/Libraries/Renderer/REVISION +++ b/Libraries/Renderer/REVISION @@ -1 +1 @@ -3ff2c7ccd4d174786aed0f16cc0dd784816ae977 \ No newline at end of file +6bf5e859860938b8cb7153ee928c01ad45656969 \ No newline at end of file diff --git a/Libraries/Renderer/oss/ReactFabric-dev.js b/Libraries/Renderer/oss/ReactFabric-dev.js index 1b716029b4ac87..6cd1ed2407d89d 100644 --- a/Libraries/Renderer/oss/ReactFabric-dev.js +++ b/Libraries/Renderer/oss/ReactFabric-dev.js @@ -2441,14 +2441,8 @@ var ResponderEventPlugin = { } }; -var customBubblingEventTypes$1 = - ReactNativeViewConfigRegistry.customBubblingEventTypes; -var customDirectEventTypes$1 = - ReactNativeViewConfigRegistry.customDirectEventTypes; -var eventTypes$2 = ReactNativeViewConfigRegistry.eventTypes; - var ReactNativeBridgeEventPlugin = { - eventTypes: eventTypes$2, + eventTypes: ReactNativeViewConfigRegistry.eventTypes, /** * @see {EventPluginHub.extractEvents} @@ -2463,8 +2457,10 @@ var ReactNativeBridgeEventPlugin = { // Probably a node belonging to another renderer's tree. return null; } - var bubbleDispatchConfig = customBubblingEventTypes$1[topLevelType]; - var directDispatchConfig = customDirectEventTypes$1[topLevelType]; + var bubbleDispatchConfig = + ReactNativeViewConfigRegistry.customBubblingEventTypes[topLevelType]; + var directDispatchConfig = + ReactNativeViewConfigRegistry.customDirectEventTypes[topLevelType]; invariant( bubbleDispatchConfig || directDispatchConfig, 'Unsupported top level event type "%s" dispatched', @@ -3639,7 +3635,7 @@ var unhideTextInstance = shim; function shim$1() { invariant( false, - "The current renderer does not support hyration. " + + "The current renderer does not support hydration. " + "This error is likely caused by a bug in React. " + "Please file an issue." ); @@ -3906,10 +3902,10 @@ function shouldSetTextContent(type, props) { // The Fabric renderer is secondary to the existing React Native renderer. var isPrimaryRenderer = false; -var now = now$1; -var scheduleDeferredCallback = scheduleDeferredCallback$1; -var cancelDeferredCallback = cancelDeferredCallback$1; -var shouldYield = shouldYield$1; +var now$$1 = now$1; +var scheduleDeferredCallback$$1 = scheduleDeferredCallback$1; +var cancelDeferredCallback$$1 = cancelDeferredCallback$1; +var shouldYield$$1 = shouldYield$1; var scheduleTimeout = setTimeout; var cancelTimeout = clearTimeout; @@ -4035,13 +4031,14 @@ var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame; function describeFiber(fiber) { switch (fiber.tag) { - case IndeterminateComponent: - case LazyComponent: - case FunctionComponent: - case ClassComponent: - case HostComponent: - case Mode: - case SuspenseComponent: + case HostRoot: + case HostPortal: + case HostText: + case Fragment: + case ContextProvider: + case ContextConsumer: + return ""; + default: var owner = fiber._debugOwner; var source = fiber._debugSource; var name = getComponentName(fiber.type); @@ -4050,8 +4047,6 @@ function describeFiber(fiber) { ownerName = getComponentName(owner.type); } return describeComponentFrame(name, source, ownerName); - default: - return ""; } } @@ -5138,6 +5133,23 @@ function FiberNode(tag, pendingProps, key, mode) { this.alternate = null; if (enableProfilerTimer) { + // Note: The following is done to avoid a v8 deopt. + // + // It is important to initialize the fields below with doubles. + // Otherwise Fibers will deopt and end up having separate shapes when + // doubles are later assigned to fields that initially contained smis. + // This is a bug in v8 having something to do with Object.preventExtension(). + // + // Learn more about this deopt here: + // https://github.com/facebook/react/issues/14365 + // https://bugs.chromium.org/p/v8/issues/detail?id=8538 + this.actualDuration = Number.NaN; + this.actualStartTime = Number.NaN; + this.selfBaseDuration = Number.NaN; + this.treeBaseDuration = Number.NaN; + + // It's okay to replace the initial doubles with smis after initialization. + // This simplifies other profiler code and doesn't trigger the deopt. this.actualDuration = 0; this.actualStartTime = -1; this.selfBaseDuration = 0; @@ -7350,7 +7362,7 @@ function cloneHook(hook) { return { memoizedState: hook.memoizedState, - baseState: hook.memoizedState, + baseState: hook.baseState, queue: hook.queue, baseUpdate: hook.baseUpdate, @@ -7601,15 +7613,6 @@ function useRef(initialValue) { return ref; } -function useMutationEffect(create, inputs) { - useEffectImpl( - Snapshot | Update, - UnmountSnapshot | MountMutation, - create, - inputs - ); -} - function useLayoutEffect(create, inputs) { useEffectImpl(Update, UnmountMutation | MountLayout, create, inputs); } @@ -7657,28 +7660,23 @@ function useImperativeMethods(ref, create, inputs) { // TODO: I've implemented this on top of useEffect because it's almost the // same thing, and it would require an equal amount of code. It doesn't seem // like a common enough use case to justify the additional size. - useEffectImpl( - Update, - UnmountMutation | MountLayout, - function() { - if (typeof ref === "function") { - var refCallback = ref; - var _inst = create(); - refCallback(_inst); - return function() { - return refCallback(null); - }; - } else if (ref !== null && ref !== undefined) { - var refObject = ref; - var _inst2 = create(); - refObject.current = _inst2; - return function() { - refObject.current = null; - }; - } - }, - nextInputs - ); + useLayoutEffect(function() { + if (typeof ref === "function") { + var refCallback = ref; + var _inst = create(); + refCallback(_inst); + return function() { + return refCallback(null); + }; + } else if (ref !== null && ref !== undefined) { + var refObject = ref; + var _inst2 = create(); + refObject.current = _inst2; + return function() { + refObject.current = null; + }; + } + }, nextInputs); } function useCallback(callback, inputs) { @@ -7870,7 +7868,7 @@ function recordCommitTime() { if (!enableProfilerTimer) { return; } - commitTime = now(); + commitTime = now$$1(); } function startProfilerTimer(fiber) { @@ -7878,10 +7876,10 @@ function startProfilerTimer(fiber) { return; } - profilerStartTime = now(); + profilerStartTime = now$$1(); if (fiber.actualStartTime < 0) { - fiber.actualStartTime = now(); + fiber.actualStartTime = now$$1(); } } @@ -7898,7 +7896,7 @@ function stopProfilerTimerIfRunningAndRecordDelta(fiber, overrideBaseTime) { } if (profilerStartTime >= 0) { - var elapsedTime = now() - profilerStartTime; + var elapsedTime = now$$1() - profilerStartTime; fiber.actualDuration += elapsedTime; if (overrideBaseTime) { fiber.selfBaseDuration = elapsedTime; @@ -10782,12 +10780,14 @@ var didWarnAboutBadClass = void 0; var didWarnAboutContextTypeOnFunctionComponent = void 0; var didWarnAboutGetDerivedStateOnFunctionComponent = void 0; var didWarnAboutFunctionRefs = void 0; +var didWarnAboutReassigningProps = void 0; { didWarnAboutBadClass = {}; didWarnAboutContextTypeOnFunctionComponent = {}; didWarnAboutGetDerivedStateOnFunctionComponent = {}; didWarnAboutFunctionRefs = {}; + didWarnAboutReassigningProps = false; } function reconcileChildren( @@ -10862,6 +10862,23 @@ function updateForwardRef( nextProps, renderExpirationTime ) { + { + if (workInProgress.type !== workInProgress.elementType) { + // Lazy component props can't be validated in createElement + // because they're only guaranteed to be resolved here. + var innerPropTypes = Component.propTypes; + if (innerPropTypes) { + checkPropTypes( + innerPropTypes, + nextProps, // Resolved props + "prop", + getComponentName(Component), + getCurrentFiberStackInDev + ); + } + } + } + var render = Component.render; var ref = workInProgress.ref; @@ -10898,12 +10915,20 @@ function updateMemoComponent( ) { if (current$$1 === null) { var type = Component.type; - if (isSimpleFunctionComponent(type) && Component.compare === null) { + if ( + isSimpleFunctionComponent(type) && + Component.compare === null && + // SimpleMemoComponent codepath doesn't resolve outer props either. + Component.defaultProps === undefined + ) { // If this is a plain function component without default props, // and with only the default shallow comparison, we upgrade it // to a SimpleMemoComponent to allow fast path updates. workInProgress.tag = SimpleMemoComponent; workInProgress.type = type; + { + validateFunctionComponentInDev(workInProgress, type); + } return updateSimpleMemoComponent( current$$1, workInProgress, @@ -10913,6 +10938,20 @@ function updateMemoComponent( renderExpirationTime ); } + { + var innerPropTypes = type.propTypes; + if (innerPropTypes) { + // Inner memo component props aren't currently validated in createElement. + // We could move it there, but we'd still need this for lazy code path. + checkPropTypes( + innerPropTypes, + nextProps, // Resolved props + "prop", + getComponentName(type), + getCurrentFiberStackInDev + ); + } + } var child = createFiberFromTypeAndProps( Component.type, null, @@ -10926,6 +10965,21 @@ function updateMemoComponent( workInProgress.child = child; return child; } + { + var _type = Component.type; + var _innerPropTypes = _type.propTypes; + if (_innerPropTypes) { + // Inner memo component props aren't currently validated in createElement. + // We could move it there, but we'd still need this for lazy code path. + checkPropTypes( + _innerPropTypes, + nextProps, // Resolved props + "prop", + getComponentName(_type), + getCurrentFiberStackInDev + ); + } + } var currentChild = current$$1.child; // This is always exactly one child if (updateExpirationTime < renderExpirationTime) { // This will be the props with resolved defaultProps, @@ -10966,6 +11020,30 @@ function updateSimpleMemoComponent( updateExpirationTime, renderExpirationTime ) { + { + if (workInProgress.type !== workInProgress.elementType) { + // Lazy component props can't be validated in createElement + // because they're only guaranteed to be resolved here. + var outerMemoType = workInProgress.elementType; + if (outerMemoType.$$typeof === REACT_LAZY_TYPE) { + // We warn when you define propTypes on lazy() + // so let's just skip over it to find memo() outer wrapper. + // Inner props for memo are validated later. + outerMemoType = refineResolvedLazyComponent(outerMemoType); + } + var outerPropTypes = outerMemoType && outerMemoType.propTypes; + if (outerPropTypes) { + checkPropTypes( + outerPropTypes, + nextProps, // Resolved (SimpleMemoComponent has no defaultProps) + "prop", + getComponentName(outerMemoType), + getCurrentFiberStackInDev + ); + } + // Inner propTypes will be validated in the function component path. + } + } if (current$$1 !== null && updateExpirationTime < renderExpirationTime) { var prevProps = current$$1.memoizedProps; if ( @@ -11043,6 +11121,23 @@ function updateFunctionComponent( nextProps, renderExpirationTime ) { + { + if (workInProgress.type !== workInProgress.elementType) { + // Lazy component props can't be validated in createElement + // because they're only guaranteed to be resolved here. + var innerPropTypes = Component.propTypes; + if (innerPropTypes) { + checkPropTypes( + innerPropTypes, + nextProps, // Resolved props + "prop", + getComponentName(Component), + getCurrentFiberStackInDev + ); + } + } + } + var unmaskedContext = getUnmaskedContext(workInProgress, Component, true); var context = getMaskedContext(workInProgress, unmaskedContext); @@ -11075,6 +11170,23 @@ function updateClassComponent( nextProps, renderExpirationTime ) { + { + if (workInProgress.type !== workInProgress.elementType) { + // Lazy component props can't be validated in createElement + // because they're only guaranteed to be resolved here. + var innerPropTypes = Component.propTypes; + if (innerPropTypes) { + checkPropTypes( + innerPropTypes, + nextProps, // Resolved props + "prop", + getComponentName(Component), + getCurrentFiberStackInDev + ); + } + } + } + // Push context providers early to prevent context stack mismatches. // During mounting we don't know the child context yet as the instance doesn't exist. // We will invalidate the child context in finishClassComponent() right after rendering. @@ -11131,7 +11243,7 @@ function updateClassComponent( renderExpirationTime ); } - return finishClassComponent( + var nextUnitOfWork = finishClassComponent( current$$1, workInProgress, Component, @@ -11139,6 +11251,21 @@ function updateClassComponent( hasContext, renderExpirationTime ); + { + var inst = workInProgress.stateNode; + if (inst.props !== nextProps) { + !didWarnAboutReassigningProps + ? warning$1( + false, + "It looks like %s is reassigning its own `this.props` while rendering. " + + "This is not supported and can lead to confusing bugs.", + getComponentName(workInProgress.type) || "a component" + ) + : void 0; + didWarnAboutReassigningProps = true; + } + } + return nextUnitOfWork; } function finishClassComponent( @@ -11441,6 +11568,20 @@ function mountLazyComponent( break; } case MemoComponent: { + { + if (workInProgress.type !== workInProgress.elementType) { + var outerPropTypes = Component.propTypes; + if (outerPropTypes) { + checkPropTypes( + outerPropTypes, + resolvedProps, // Resolved for outer only + "prop", + getComponentName(Component), + getCurrentFiberStackInDev + ); + } + } + } child = updateMemoComponent( null, workInProgress, @@ -11452,14 +11593,25 @@ function mountLazyComponent( break; } default: { - // This message intentionally doesn't metion ForwardRef or MemoComponent + var hint = ""; + { + if ( + Component !== null && + typeof Component === "object" && + Component.$$typeof === REACT_LAZY_TYPE + ) { + hint = " Did you wrap a component in React.lazy() more than once?"; + } + } + // This message intentionally doesn't mention ForwardRef or MemoComponent // because the fact that it's a separate type of work is an // implementation detail. invariant( false, "Element type is invalid. Received a promise that resolves to: %s. " + - "Promise elements must resolve to a class or function.", - Component + "Lazy element type must resolve to a class or function.%s", + Component, + hint ); } } @@ -11629,70 +11781,74 @@ function mountIndeterminateComponent( // Proceed under the assumption that this is a function component workInProgress.tag = FunctionComponent; value = finishHooks(Component, props, value, context); + reconcileChildren(null, workInProgress, value, renderExpirationTime); { - if (Component) { - !!Component.childContextTypes - ? warningWithoutStack$1( - false, - "%s(...): childContextTypes cannot be defined on a function component.", - Component.displayName || Component.name || "Component" - ) - : void 0; - } - if (workInProgress.ref !== null) { - var info = ""; - var ownerName = getCurrentFiberOwnerNameInDevOrNull(); - if (ownerName) { - info += "\n\nCheck the render method of `" + ownerName + "`."; - } + validateFunctionComponentInDev(workInProgress, Component); + } + return workInProgress.child; + } +} - var warningKey = ownerName || workInProgress._debugID || ""; - var debugSource = workInProgress._debugSource; - if (debugSource) { - warningKey = debugSource.fileName + ":" + debugSource.lineNumber; - } - if (!didWarnAboutFunctionRefs[warningKey]) { - didWarnAboutFunctionRefs[warningKey] = true; - warning$1( - false, - "Function components cannot be given refs. " + - "Attempts to access this ref will fail.%s", - info - ); - } - } +function validateFunctionComponentInDev(workInProgress, Component) { + if (Component) { + !!Component.childContextTypes + ? warningWithoutStack$1( + false, + "%s(...): childContextTypes cannot be defined on a function component.", + Component.displayName || Component.name || "Component" + ) + : void 0; + } + if (workInProgress.ref !== null) { + var info = ""; + var ownerName = getCurrentFiberOwnerNameInDevOrNull(); + if (ownerName) { + info += "\n\nCheck the render method of `" + ownerName + "`."; + } - if (typeof Component.getDerivedStateFromProps === "function") { - var _componentName = getComponentName(Component) || "Unknown"; + var warningKey = ownerName || workInProgress._debugID || ""; + var debugSource = workInProgress._debugSource; + if (debugSource) { + warningKey = debugSource.fileName + ":" + debugSource.lineNumber; + } + if (!didWarnAboutFunctionRefs[warningKey]) { + didWarnAboutFunctionRefs[warningKey] = true; + warning$1( + false, + "Function components cannot be given refs. " + + "Attempts to access this ref will fail.%s", + info + ); + } + } - if (!didWarnAboutGetDerivedStateOnFunctionComponent[_componentName]) { - warningWithoutStack$1( - false, - "%s: Function components do not support getDerivedStateFromProps.", - _componentName - ); - didWarnAboutGetDerivedStateOnFunctionComponent[_componentName] = true; - } - } + if (typeof Component.getDerivedStateFromProps === "function") { + var componentName = getComponentName(Component) || "Unknown"; - if ( - typeof Component.contextType === "object" && - Component.contextType !== null - ) { - var _componentName2 = getComponentName(Component) || "Unknown"; + if (!didWarnAboutGetDerivedStateOnFunctionComponent[componentName]) { + warningWithoutStack$1( + false, + "%s: Function components do not support getDerivedStateFromProps.", + componentName + ); + didWarnAboutGetDerivedStateOnFunctionComponent[componentName] = true; + } + } - if (!didWarnAboutContextTypeOnFunctionComponent[_componentName2]) { - warningWithoutStack$1( - false, - "%s: Function components do not support contextType.", - _componentName2 - ); - didWarnAboutContextTypeOnFunctionComponent[_componentName2] = true; - } - } + if ( + typeof Component.contextType === "object" && + Component.contextType !== null + ) { + var _componentName = getComponentName(Component) || "Unknown"; + + if (!didWarnAboutContextTypeOnFunctionComponent[_componentName]) { + warningWithoutStack$1( + false, + "%s: Function components do not support contextType.", + _componentName + ); + didWarnAboutContextTypeOnFunctionComponent[_componentName] = true; } - reconcileChildren(null, workInProgress, value, renderExpirationTime); - return workInProgress.child; } } @@ -11817,7 +11973,6 @@ function updateSuspenseComponent( currentPrimaryChildFragment.pendingProps, NoWork ); - _primaryChildFragment.effectTag |= Placement; if ((workInProgress.mode & ConcurrentMode) === NoContext) { // Outside of concurrent mode, we commit the effects from the @@ -11851,7 +12006,6 @@ function updateSuspenseComponent( _nextFallbackChildren, currentFallbackChildFragment.expirationTime )); - _fallbackChildFragment.effectTag |= Placement; child = _primaryChildFragment; _primaryChildFragment.childExpirationTime = NoWork; // Skip the primary children, and continue working on the @@ -11881,6 +12035,7 @@ function updateSuspenseComponent( } } else { // The current tree has not already timed out. That means the primary + // children are not wrapped in a fragment fiber. var _currentPrimaryChild = current$$1.child; if (nextDidTimeout) { // Timed out. Wrap the children in a fragment fiber to keep them @@ -11894,10 +12049,12 @@ function updateSuspenseComponent( NoWork, null ); - - _primaryChildFragment2.effectTag |= Placement; _primaryChildFragment2.child = _currentPrimaryChild; - _currentPrimaryChild.return = _primaryChildFragment2; + + // Even though we're creating a new fiber, there are no new children, + // because we're reusing an already mounted tree. So we don't need to + // schedule a placement. + // primaryChildFragment.effectTag |= Placement; if ((workInProgress.mode & ConcurrentMode) === NoContext) { // Outside of concurrent mode, we commit the effects from the @@ -12353,13 +12510,29 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { renderExpirationTime ); case MemoComponent: { - var _type = workInProgress.type; + var _type2 = workInProgress.type; var _unresolvedProps3 = workInProgress.pendingProps; - var _resolvedProps3 = resolveDefaultProps(_type.type, _unresolvedProps3); + // Resolve outer props first, then resolve inner props. + var _resolvedProps3 = resolveDefaultProps(_type2, _unresolvedProps3); + { + if (workInProgress.type !== workInProgress.elementType) { + var outerPropTypes = _type2.propTypes; + if (outerPropTypes) { + checkPropTypes( + outerPropTypes, + _resolvedProps3, // Resolved for outer only + "prop", + getComponentName(_type2), + getCurrentFiberStackInDev + ); + } + } + } + _resolvedProps3 = resolveDefaultProps(_type2.type, _resolvedProps3); return updateMemoComponent( current$$1, workInProgress, - _type, + _type2, _resolvedProps3, updateExpirationTime, renderExpirationTime @@ -13006,12 +13179,16 @@ function completeWork(current, workInProgress, renderExpirationTime) { // TODO: Would it be better to store the fallback fragment on var currentFallbackChild = current.child.sibling; if (currentFallbackChild !== null) { - reconcileChildFibers( - workInProgress, - currentFallbackChild, - null, - renderExpirationTime - ); + // Deletions go at the beginning of the return fiber's effect list + var first = workInProgress.firstEffect; + if (first !== null) { + workInProgress.firstEffect = currentFallbackChild; + currentFallbackChild.nextEffect = first; + } else { + workInProgress.firstEffect = workInProgress.lastEffect = currentFallbackChild; + currentFallbackChild.nextEffect = null; + } + currentFallbackChild.effectTag = Deletion; } } @@ -13309,21 +13486,30 @@ function commitBeforeMutationLifeCycles(current$$1, finishedWork) { // but instead we rely on them being set during last render. // TODO: revisit this when we implement resuming. { - if (finishedWork.type === finishedWork.elementType) { + if ( + finishedWork.type === finishedWork.elementType && + !didWarnAboutReassigningProps + ) { !(instance.props === finishedWork.memoizedProps) ? warning$1( false, - "Expected instance props to match memoized props before " + - "getSnapshotBeforeUpdate. This is likely due to a bug in React. " + - "Please file an issue." + "Expected %s props to match memoized props before " + + "getSnapshotBeforeUpdate. " + + "This might either be because of a bug in React, or because " + + "a component reassigns its own `this.props`. " + + "Please file an issue.", + getComponentName(finishedWork.type) || "instance" ) : void 0; !(instance.state === finishedWork.memoizedState) ? warning$1( false, - "Expected instance state to match memoized state before " + - "getSnapshotBeforeUpdate. This is likely due to a bug in React. " + - "Please file an issue." + "Expected %s state to match memoized state before " + + "getSnapshotBeforeUpdate. " + + "This might either be because of a bug in React, or because " + + "a component reassigns its own `this.props`. " + + "Please file an issue.", + getComponentName(finishedWork.type) || "instance" ) : void 0; } @@ -13399,9 +13585,17 @@ function commitHookEffectList(unmountTag, mountTag, finishedWork) { "useEffect function must return a cleanup function or " + "nothing.%s%s", typeof _destroy.then === "function" - ? " Promises and useEffect(async () => ...) are not " + - "supported, but you can call an async function inside an " + - "effect." + ? "\n\nIt looks like you wrote useEffect(async () => ...) or returned a Promise. " + + "Instead, you may write an async function separately " + + "and then call it from inside the effect:\n\n" + + "async function fetchComment(commentId) {\n" + + " // You can await here\n" + + "}\n\n" + + "useEffect(() => {\n" + + " fetchComment(commentId);\n" + + "}, [commentId]);\n\n" + + "In the future, React will provide a more idiomatic solution for data fetching " + + "that doesn't involve writing effects manually." : "", getStackByFiberInDevAndProd(finishedWork) ); @@ -13443,21 +13637,30 @@ function commitLifeCycles( // but instead we rely on them being set during last render. // TODO: revisit this when we implement resuming. { - if (finishedWork.type === finishedWork.elementType) { + if ( + finishedWork.type === finishedWork.elementType && + !didWarnAboutReassigningProps + ) { !(instance.props === finishedWork.memoizedProps) ? warning$1( false, - "Expected instance props to match memoized props before " + - "componentDidMount. This is likely due to a bug in React. " + - "Please file an issue." + "Expected %s props to match memoized props before " + + "componentDidMount. " + + "This might either be because of a bug in React, or because " + + "a component reassigns its own `this.props`. " + + "Please file an issue.", + getComponentName(finishedWork.type) || "instance" ) : void 0; !(instance.state === finishedWork.memoizedState) ? warning$1( false, - "Expected instance state to match memoized state before " + - "componentDidMount. This is likely due to a bug in React. " + - "Please file an issue." + "Expected %s state to match memoized state before " + + "componentDidMount. " + + "This might either be because of a bug in React, or because " + + "a component reassigns its own `this.props`. " + + "Please file an issue.", + getComponentName(finishedWork.type) || "instance" ) : void 0; } @@ -13478,21 +13681,30 @@ function commitLifeCycles( // but instead we rely on them being set during last render. // TODO: revisit this when we implement resuming. { - if (finishedWork.type === finishedWork.elementType) { + if ( + finishedWork.type === finishedWork.elementType && + !didWarnAboutReassigningProps + ) { !(instance.props === finishedWork.memoizedProps) ? warning$1( false, - "Expected instance props to match memoized props before " + - "componentDidUpdate. This is likely due to a bug in React. " + - "Please file an issue." + "Expected %s props to match memoized props before " + + "componentDidUpdate. " + + "This might either be because of a bug in React, or because " + + "a component reassigns its own `this.props`. " + + "Please file an issue.", + getComponentName(finishedWork.type) || "instance" ) : void 0; !(instance.state === finishedWork.memoizedState) ? warning$1( false, - "Expected instance state to match memoized state before " + - "componentDidUpdate. This is likely due to a bug in React. " + - "Please file an issue." + "Expected %s state to match memoized state before " + + "componentDidUpdate. " + + "This might either be because of a bug in React, or because " + + "a component reassigns its own `this.props`. " + + "Please file an issue.", + getComponentName(finishedWork.type) || "instance" ) : void 0; } @@ -13508,21 +13720,30 @@ function commitLifeCycles( var updateQueue = finishedWork.updateQueue; if (updateQueue !== null) { { - if (finishedWork.type === finishedWork.elementType) { + if ( + finishedWork.type === finishedWork.elementType && + !didWarnAboutReassigningProps + ) { !(instance.props === finishedWork.memoizedProps) ? warning$1( false, - "Expected instance props to match memoized props before " + - "processing the update queue. This is likely due to a bug in React. " + - "Please file an issue." + "Expected %s props to match memoized props before " + + "processing the update queue. " + + "This might either be because of a bug in React, or because " + + "a component reassigns its own `this.props`. " + + "Please file an issue.", + getComponentName(finishedWork.type) || "instance" ) : void 0; !(instance.state === finishedWork.memoizedState) ? warning$1( false, - "Expected instance state to match memoized state before " + - "processing the update queue. This is likely due to a bug in React. " + - "Please file an issue." + "Expected %s state to match memoized state before " + + "processing the update queue. " + + "This might either be because of a bug in React, or because " + + "a component reassigns its own `this.props`. " + + "Please file an issue.", + getComponentName(finishedWork.type) || "instance" ) : void 0; } @@ -13645,6 +13866,15 @@ function hideOrUnhideAllChildren(finishedWork, isHidden) { } else { unhideTextInstance(_instance3, node.memoizedProps); } + } else if ( + node.tag === SuspenseComponent && + node.memoizedState !== null + ) { + // Found a nested Suspense component that timed out. Skip over the + var fallbackChildFragment = node.child.sibling; + fallbackChildFragment.return = node; + node = fallbackChildFragment; + continue; } else if (node.child !== null) { node.child.return = node; node = node.child; @@ -13804,9 +14034,14 @@ function detachFiber(current$$1) { // itself will be GC:ed when the parent updates the next time. current$$1.return = null; current$$1.child = null; - if (current$$1.alternate) { - current$$1.alternate.child = null; - current$$1.alternate.return = null; + current$$1.memoizedState = null; + current$$1.updateQueue = null; + var alternate = current$$1.alternate; + if (alternate !== null) { + alternate.return = null; + alternate.child = null; + alternate.memoizedState = null; + alternate.updateQueue = null; } } @@ -14107,6 +14342,8 @@ function commitWork(current$$1, finishedWork) { case ForwardRef: case MemoComponent: case SimpleMemoComponent: { + // Note: We currently never use MountMutation, but useLayout uses + // UnmountMutation. commitHookEffectList(UnmountMutation, MountMutation, finishedWork); return; } @@ -14121,6 +14358,8 @@ function commitWork(current$$1, finishedWork) { case ForwardRef: case MemoComponent: case SimpleMemoComponent: { + // Note: We currently never use MountMutation, but useLayout uses + // UnmountMutation. commitHookEffectList(UnmountMutation, MountMutation, finishedWork); return; } @@ -14378,20 +14617,10 @@ function throwException( if ((_workInProgress.mode & ConcurrentMode) === NoEffect) { _workInProgress.effectTag |= DidCapture; - // Unmount the source fiber's children - var nextChildren = null; - reconcileChildren( - sourceFiber.alternate, - sourceFiber, - nextChildren, - renderExpirationTime - ); - sourceFiber.effectTag &= ~Incomplete; - // We're going to commit this fiber even though it didn't complete. // But we shouldn't call any lifecycle methods or callbacks. Remove // all lifecycle effect tags. - sourceFiber.effectTag &= ~LifecycleEffectMask; + sourceFiber.effectTag &= ~(LifecycleEffectMask | Incomplete); if (sourceFiber.tag === ClassComponent) { var _current = sourceFiber.alternate; @@ -14607,7 +14836,6 @@ var Dispatcher = { useImperativeMethods: useImperativeMethods, useLayoutEffect: useLayoutEffect, useMemo: useMemo, - useMutationEffect: useMutationEffect, useReducer: useReducer, useRef: useRef, useState: useState @@ -14625,12 +14853,12 @@ var warnAboutInvalidUpdates = void 0; if (enableSchedulerTracing) { // Provide explicit error message when production+profiling bundle of e.g. react-dom - // is used with production (non-profiling) bundle of schedule/tracing + // is used with production (non-profiling) bundle of scheduler/tracing invariant( 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/tracing` module with `schedule/tracing-profiling`. " + + "without also replacing the `scheduler/tracing` module with `scheduler/tracing-profiling`. " + "Your bundler might have a setting for aliasing both modules. " + "Learn more at http://fb.me/react-profiling" ); @@ -16127,6 +16355,46 @@ function scheduleWorkToRoot(fiber, expirationTime) { } } + if (enableSchedulerTracing) { + if (root !== null) { + 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 { + pendingInteractionMap.set(expirationTime, new Set(interactions)); + + // Update the pending async work count for the current interactions. + interactions.forEach(function(interaction) { + interaction.__count++; + }); + } + + var subscriber = tracing.__subscriberRef.current; + if (subscriber !== null) { + var threadID = computeThreadID( + expirationTime, + root.interactionThreadID + ); + subscriber.onWorkScheduled(interactions, threadID); + } + } + } + } + return root; +} + +function scheduleWork(fiber, expirationTime) { + var root = scheduleWorkToRoot(fiber, expirationTime); if (root === null) { { switch (fiber.tag) { @@ -16141,49 +16409,6 @@ function scheduleWorkToRoot(fiber, expirationTime) { break; } } - return null; - } - - 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 { - pendingInteractionMap.set(expirationTime, new Set(interactions)); - - // Update the pending async work count for the current interactions. - interactions.forEach(function(interaction) { - interaction.__count++; - }); - } - - var subscriber = tracing.__subscriberRef.current; - if (subscriber !== null) { - var threadID = computeThreadID( - expirationTime, - root.interactionThreadID - ); - subscriber.onWorkScheduled(interactions, threadID); - } - } - } - - return root; -} - -function scheduleWork(fiber, expirationTime) { - var root = scheduleWorkToRoot(fiber, expirationTime); - if (root === null) { return; } @@ -16243,7 +16468,7 @@ var isBatchingInteractiveUpdates = false; var completedBatches = null; -var originalStartTimeMs = now(); +var originalStartTimeMs = now$$1(); var currentRendererTime = msToExpirationTime(originalStartTimeMs); var currentSchedulerTime = currentRendererTime; @@ -16253,7 +16478,7 @@ var nestedUpdateCount = 0; var lastCommittedRootDuringThisBatch = null; function recomputeCurrentRendererTime() { - var currentTimeMs = now() - originalStartTimeMs; + var currentTimeMs = now$$1() - originalStartTimeMs; currentRendererTime = msToExpirationTime(currentTimeMs); } @@ -16267,7 +16492,7 @@ function scheduleCallbackWithExpirationTime(root, expirationTime) { if (callbackID !== null) { // Existing callback has insufficient timeout. Cancel and schedule a // new one. - cancelDeferredCallback(callbackID); + cancelDeferredCallback$$1(callbackID); } } // The request callback timer is already running. Don't start a new one. @@ -16276,10 +16501,12 @@ function scheduleCallbackWithExpirationTime(root, expirationTime) { } callbackExpirationTime = expirationTime; - var currentMs = now() - originalStartTimeMs; + var currentMs = now$$1() - originalStartTimeMs; var expirationTimeMs = expirationTimeToMs(expirationTime); var timeout = expirationTimeMs - currentMs; - callbackID = scheduleDeferredCallback(performAsyncWork, { timeout: timeout }); + callbackID = scheduleDeferredCallback$$1(performAsyncWork, { + timeout: timeout + }); } // For every call to renderRoot, one of onFatal, onComplete, onSuspend, and @@ -16508,7 +16735,7 @@ function shouldYieldToRenderer() { if (didYield) { return true; } - if (shouldYield()) { + if (shouldYield$$1()) { didYield = true; return true; } @@ -16930,7 +17157,7 @@ function updateContainerAtExpirationTime( return scheduleRootUpdate(current$$1, element, expirationTime, callback); } -function findHostInstance$1(component) { +function findHostInstance(component) { var fiber = get$1(component); if (fiber === undefined) { if (typeof component.render === "function") { @@ -16950,7 +17177,7 @@ function findHostInstance$1(component) { return hostFiber.stateNode; } -function findHostInstanceWithWarning$1(component, methodName) { +function findHostInstanceWithWarning(component, methodName) { { var fiber = get$1(component); if (fiber === undefined) { @@ -17005,7 +17232,7 @@ function findHostInstanceWithWarning$1(component, methodName) { } return hostFiber.stateNode; } - return findHostInstance$1(component); + return findHostInstance(component); } function createContainer(containerInfo, isConcurrent, hydrate) { @@ -17594,8 +17821,6 @@ var getInspectorDataForViewTag = void 0; } var ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner; -var findHostInstance = findHostInstance$1; -var findHostInstanceWithWarning = findHostInstanceWithWarning$1; function findNodeHandle(componentOrHandle) { { diff --git a/Libraries/Renderer/oss/ReactFabric-prod.js b/Libraries/Renderer/oss/ReactFabric-prod.js index cc9b81203f0a70..95eeffce359f83 100644 --- a/Libraries/Renderer/oss/ReactFabric-prod.js +++ b/Libraries/Renderer/oss/ReactFabric-prod.js @@ -956,10 +956,6 @@ var eventTypes$1 = { } } }, - customBubblingEventTypes$1 = - ReactNativeViewConfigRegistry.customBubblingEventTypes, - customDirectEventTypes$1 = - ReactNativeViewConfigRegistry.customDirectEventTypes, ReactNativeBridgeEventPlugin = { eventTypes: ReactNativeViewConfigRegistry.eventTypes, extractEvents: function( @@ -969,8 +965,10 @@ var eventTypes$1 = { nativeEventTarget ) { if (null == targetInst) return null; - var bubbleDispatchConfig = customBubblingEventTypes$1[topLevelType], - directDispatchConfig = customDirectEventTypes$1[topLevelType]; + var bubbleDispatchConfig = + ReactNativeViewConfigRegistry.customBubblingEventTypes[topLevelType], + directDispatchConfig = + ReactNativeViewConfigRegistry.customDirectEventTypes[topLevelType]; invariant( bubbleDispatchConfig || directDispatchConfig, 'Unsupported top level event type "%s" dispatched', @@ -1505,7 +1503,7 @@ function dispatchEvent(target, topLevelType, nativeEvent) { function shim$1() { invariant( !1, - "The current renderer does not support hyration. This error is likely caused by a bug in React. Please file an issue." + "The current renderer does not support hydration. This error is likely caused by a bug in React. Please file an issue." ); } var nextReactTag = 2; @@ -1619,17 +1617,19 @@ function getStackByFiberInDevAndProd(workInProgress) { var info = ""; do { a: switch (workInProgress.tag) { - case 2: - case 16: - case 0: - case 1: - case 5: - case 8: - case 13: + case 3: + case 4: + case 6: + case 7: + case 10: + case 9: + var JSCompiler_inline_result = ""; + break a; + default: var owner = workInProgress._debugOwner, source = workInProgress._debugSource, name = getComponentName(workInProgress.type); - var JSCompiler_inline_result = null; + JSCompiler_inline_result = null; owner && (JSCompiler_inline_result = getComponentName(owner.type)); owner = name; name = ""; @@ -1643,9 +1643,6 @@ function getStackByFiberInDevAndProd(workInProgress) { : JSCompiler_inline_result && (name = " (created by " + JSCompiler_inline_result + ")"); JSCompiler_inline_result = "\n in " + (owner || "Unknown") + name; - break a; - default: - JSCompiler_inline_result = ""; } info += JSCompiler_inline_result; workInProgress = workInProgress.return; @@ -3379,7 +3376,8 @@ function updateMemoComponent( "function" === typeof type && !shouldConstruct(type) && void 0 === type.defaultProps && - null === Component.compare + null === Component.compare && + void 0 === Component.defaultProps ) return ( (workInProgress.tag = 15), @@ -3817,7 +3815,6 @@ function updateSuspenseComponent( nextDidTimeout ? ((renderExpirationTime = nextProps.fallback), (nextProps = createWorkInProgress(mode, mode.pendingProps, 0)), - (nextProps.effectTag |= 2), 0 === (workInProgress.mode & 1) && ((nextDidTimeout = null !== workInProgress.memoizedState @@ -3830,7 +3827,6 @@ function updateSuspenseComponent( renderExpirationTime, current$$1.expirationTime )), - (mode.effectTag |= 2), (renderExpirationTime = nextProps), (nextProps.childExpirationTime = 0), (renderExpirationTime.return = mode.return = workInProgress)) @@ -3844,9 +3840,7 @@ function updateSuspenseComponent( nextDidTimeout ? ((nextDidTimeout = nextProps.fallback), (nextProps = createFiberFromFragment(null, mode, 0, null)), - (nextProps.effectTag |= 2), (nextProps.child = current$$1), - (current$$1.return = nextProps), 0 === (workInProgress.mode & 1) && (nextProps.child = null !== workInProgress.memoizedState @@ -4082,8 +4076,9 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { default: invariant( !1, - "Element type is invalid. Received a promise that resolves to: %s. Promise elements must resolve to a class or function.", - current$$1 + "Element type is invalid. Received a promise that resolves to: %s. Lazy element type must resolve to a class or function.%s", + current$$1, + "" ); } return getDerivedStateFromProps; @@ -4390,9 +4385,10 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { return ( (context = workInProgress.type), (hasContext = resolveDefaultProps( - context.type, + context, workInProgress.pendingProps )), + (hasContext = resolveDefaultProps(context.type, hasContext)), updateMemoComponent( current$$1, workInProgress, @@ -4979,20 +4975,22 @@ function completeUnitOfWork(workInProgress) { break a; } instance = null !== instance; - viewConfig = null !== current && null !== current.memoizedState; + renderExpirationTime = + null !== current && null !== current.memoizedState; null !== current && !instance && - viewConfig && + renderExpirationTime && ((current = current.child.sibling), null !== current && - reconcileChildFibers( - current$$1, - current, - null, - renderExpirationTime - )); + ((viewConfig = current$$1.firstEffect), + null !== viewConfig + ? ((current$$1.firstEffect = current), + (current.nextEffect = viewConfig)) + : ((current$$1.firstEffect = current$$1.lastEffect = current), + (current.nextEffect = null)), + (current.effectTag = 8))); if ( - instance !== viewConfig || + instance !== renderExpirationTime || (0 === (current$$1.effectTag & 1) && instance) ) current$$1.effectTag |= 4; @@ -5183,14 +5181,7 @@ function renderRoot(root$jscomp$0, isYieldy) { thenable.then(returnFiber$jscomp$0, returnFiber$jscomp$0); if (0 === (value.mode & 1)) { value.effectTag |= 64; - reconcileChildren( - sourceFiber$jscomp$0.alternate, - sourceFiber$jscomp$0, - null, - returnFiber - ); - sourceFiber$jscomp$0.effectTag &= -1025; - sourceFiber$jscomp$0.effectTag &= -933; + sourceFiber$jscomp$0.effectTag &= -1957; 1 === sourceFiber$jscomp$0.tag && null === sourceFiber$jscomp$0.alternate && (sourceFiber$jscomp$0.tag = 17); @@ -5447,7 +5438,7 @@ function scheduleWorkToRoot(fiber, expirationTime) { } node = node.return; } - return null === root ? null : root; + return root; } function scheduleWork(fiber, expirationTime) { fiber = scheduleWorkToRoot(fiber, expirationTime); @@ -5944,9 +5935,14 @@ function completeRoot$1(root, finishedWork$jscomp$0, expirationTime) { } prevState.return = null; prevState.child = null; - prevState.alternate && - ((prevState.alternate.child = null), - (prevState.alternate.return = null)); + prevState.memoizedState = null; + prevState.updateQueue = null; + var alternate = prevState.alternate; + null !== alternate && + ((alternate.return = null), + (alternate.child = null), + (alternate.memoizedState = null), + (alternate.updateQueue = null)); } nextEffect = nextEffect.nextEffect; } @@ -6101,7 +6097,7 @@ function onUncaughtError(error) { nextFlushedRoot.expirationTime = 0; hasUnhandledError || ((hasUnhandledError = !0), (unhandledError = error)); } -function findHostInstance$1(component) { +function findHostInstance(component) { var fiber = component._reactInternalFiber; void 0 === fiber && ("function" === typeof component.render @@ -6214,7 +6210,7 @@ function findNodeHandle(componentOrHandle) { if (componentOrHandle._nativeTag) return componentOrHandle._nativeTag; if (componentOrHandle.canonical && componentOrHandle.canonical._nativeTag) return componentOrHandle.canonical._nativeTag; - componentOrHandle = findHostInstance$1(componentOrHandle); + componentOrHandle = findHostInstance(componentOrHandle); return null == componentOrHandle ? componentOrHandle : componentOrHandle.canonical @@ -6310,7 +6306,7 @@ var roots = new Map(), }; return ReactNativeComponent; })(React.Component); - })(findNodeHandle, findHostInstance$1), + })(findNodeHandle, findHostInstance), findNodeHandle: findNodeHandle, render: function(element, containerTag, callback) { var root = roots.get(containerTag); @@ -6418,7 +6414,7 @@ var roots = new Map(), TextInputState.blurTextInput(findNodeHandle(this)); } }; - })(findNodeHandle, findHostInstance$1) + })(findNodeHandle, findHostInstance) } }; (function(devToolsConfig) { diff --git a/Libraries/Renderer/oss/ReactFabric-profiling.js b/Libraries/Renderer/oss/ReactFabric-profiling.js index 8f3f835d7c0a10..f327de43d86241 100644 --- a/Libraries/Renderer/oss/ReactFabric-profiling.js +++ b/Libraries/Renderer/oss/ReactFabric-profiling.js @@ -957,10 +957,6 @@ var eventTypes$1 = { } } }, - customBubblingEventTypes$1 = - ReactNativeViewConfigRegistry.customBubblingEventTypes, - customDirectEventTypes$1 = - ReactNativeViewConfigRegistry.customDirectEventTypes, ReactNativeBridgeEventPlugin = { eventTypes: ReactNativeViewConfigRegistry.eventTypes, extractEvents: function( @@ -970,8 +966,10 @@ var eventTypes$1 = { nativeEventTarget ) { if (null == targetInst) return null; - var bubbleDispatchConfig = customBubblingEventTypes$1[topLevelType], - directDispatchConfig = customDirectEventTypes$1[topLevelType]; + var bubbleDispatchConfig = + ReactNativeViewConfigRegistry.customBubblingEventTypes[topLevelType], + directDispatchConfig = + ReactNativeViewConfigRegistry.customDirectEventTypes[topLevelType]; invariant( bubbleDispatchConfig || directDispatchConfig, 'Unsupported top level event type "%s" dispatched', @@ -1506,7 +1504,7 @@ function dispatchEvent(target, topLevelType, nativeEvent) { function shim$1() { invariant( !1, - "The current renderer does not support hyration. This error is likely caused by a bug in React. Please file an issue." + "The current renderer does not support hydration. This error is likely caused by a bug in React. Please file an issue." ); } var nextReactTag = 2; @@ -1620,17 +1618,19 @@ function getStackByFiberInDevAndProd(workInProgress) { var info = ""; do { a: switch (workInProgress.tag) { - case 2: - case 16: - case 0: - case 1: - case 5: - case 8: - case 13: + case 3: + case 4: + case 6: + case 7: + case 10: + case 9: + var JSCompiler_inline_result = ""; + break a; + default: var owner = workInProgress._debugOwner, source = workInProgress._debugSource, name = getComponentName(workInProgress.type); - var JSCompiler_inline_result = null; + JSCompiler_inline_result = null; owner && (JSCompiler_inline_result = getComponentName(owner.type)); owner = name; name = ""; @@ -1644,9 +1644,6 @@ function getStackByFiberInDevAndProd(workInProgress) { : JSCompiler_inline_result && (name = " (created by " + JSCompiler_inline_result + ")"); JSCompiler_inline_result = "\n in " + (owner || "Unknown") + name; - break a; - default: - JSCompiler_inline_result = ""; } info += JSCompiler_inline_result; workInProgress = workInProgress.return; @@ -3437,7 +3434,8 @@ function updateMemoComponent( "function" === typeof type && !shouldConstruct(type) && void 0 === type.defaultProps && - null === Component.compare + null === Component.compare && + void 0 === Component.defaultProps ) return ( (workInProgress.tag = 15), @@ -3885,7 +3883,6 @@ function updateSuspenseComponent( current$$1.pendingProps, 0 ); - renderExpirationTime.effectTag |= 2; 0 === (workInProgress.mode & 1) && ((nextDidTimeout = null !== workInProgress.memoizedState @@ -3905,7 +3902,6 @@ function updateSuspenseComponent( nextProps, mode.expirationTime ); - nextProps.effectTag |= 2; mode = renderExpirationTime; renderExpirationTime.childExpirationTime = 0; renderExpirationTime = nextProps; @@ -3920,9 +3916,7 @@ function updateSuspenseComponent( else if (((current$$1 = current$$1.child), nextDidTimeout)) { nextDidTimeout = nextProps.fallback; nextProps = createFiberFromFragment(null, mode, 0, null); - nextProps.effectTag |= 2; nextProps.child = current$$1; - current$$1.return = nextProps; 0 === (workInProgress.mode & 1) && (nextProps.child = null !== workInProgress.memoizedState @@ -4170,8 +4164,9 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { default: invariant( !1, - "Element type is invalid. Received a promise that resolves to: %s. Promise elements must resolve to a class or function.", - current$$1 + "Element type is invalid. Received a promise that resolves to: %s. Lazy element type must resolve to a class or function.%s", + current$$1, + "" ); } return getDerivedStateFromProps; @@ -4479,9 +4474,10 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { return ( (context = workInProgress.type), (hasContext = resolveDefaultProps( - context.type, + context, workInProgress.pendingProps )), + (hasContext = resolveDefaultProps(context.type, hasContext)), updateMemoComponent( current$$1, workInProgress, @@ -4906,14 +4902,7 @@ function throwException( thenable.then(returnFiber, returnFiber); if (0 === (value.mode & 1)) { value.effectTag |= 64; - reconcileChildren( - sourceFiber.alternate, - sourceFiber, - null, - renderExpirationTime - ); - sourceFiber.effectTag &= -1025; - sourceFiber.effectTag &= -933; + sourceFiber.effectTag &= -1957; 1 === sourceFiber.tag && null === sourceFiber.alternate && (sourceFiber.tag = 17); @@ -5033,7 +5022,7 @@ var DispatcherWithoutHooks = { readContext: readContext }, invariant( 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" + "It is not supported to run the profiling version of a renderer (for example, `react-dom/profiling`) without also replacing the `scheduler/tracing` module with `scheduler/tracing-profiling`. Your bundler might have a setting for aliasing both modules. Learn more at http://fb.me/react-profiling" ); var isWorking = !1, nextUnitOfWork = null, @@ -5171,9 +5160,14 @@ function commitAllHostEffects() { } effectTag.return = null; effectTag.child = null; - effectTag.alternate && - ((effectTag.alternate.child = null), - (effectTag.alternate.return = null)); + effectTag.memoizedState = null; + effectTag.updateQueue = null; + effectTag = effectTag.alternate; + null !== effectTag && + ((effectTag.return = null), + (effectTag.child = null), + (effectTag.memoizedState = null), + (effectTag.updateQueue = null)); } nextEffect = nextEffect.nextEffect; } @@ -5586,20 +5580,22 @@ function completeUnitOfWork(workInProgress) { break a; } fiber = null !== fiber; - viewConfig = null !== current && null !== current.memoizedState; + renderExpirationTime = + null !== current && null !== current.memoizedState; null !== current && !fiber && - viewConfig && + renderExpirationTime && ((current = current.child.sibling), null !== current && - reconcileChildFibers( - current$$1, - current, - null, - renderExpirationTime - )); + ((viewConfig = current$$1.firstEffect), + null !== viewConfig + ? ((current$$1.firstEffect = current), + (current.nextEffect = viewConfig)) + : ((current$$1.firstEffect = current$$1.lastEffect = current), + (current.nextEffect = null)), + (current.effectTag = 8))); if ( - fiber !== viewConfig || + fiber !== renderExpirationTime || (0 === (current$$1.effectTag & 1) && fiber) ) current$$1.effectTag |= 4; @@ -5959,9 +5955,10 @@ function scheduleWorkToRoot(fiber, expirationTime) { } node = node.return; } - if (null === root) return null; - fiber = tracing.__interactionsRef.current; - if (0 < fiber.size) { + if ( + null !== root && + ((fiber = tracing.__interactionsRef.current), 0 < fiber.size) + ) { alternate = root.pendingInteractionMap; var pendingInteractions = alternate.get(expirationTime); null != pendingInteractions @@ -6290,7 +6287,7 @@ function onUncaughtError(error) { nextFlushedRoot.expirationTime = 0; hasUnhandledError || ((hasUnhandledError = !0), (unhandledError = error)); } -function findHostInstance$1(component) { +function findHostInstance(component) { var fiber = component._reactInternalFiber; void 0 === fiber && ("function" === typeof component.render @@ -6403,7 +6400,7 @@ function findNodeHandle(componentOrHandle) { if (componentOrHandle._nativeTag) return componentOrHandle._nativeTag; if (componentOrHandle.canonical && componentOrHandle.canonical._nativeTag) return componentOrHandle.canonical._nativeTag; - componentOrHandle = findHostInstance$1(componentOrHandle); + componentOrHandle = findHostInstance(componentOrHandle); return null == componentOrHandle ? componentOrHandle : componentOrHandle.canonical @@ -6499,7 +6496,7 @@ var roots = new Map(), }; return ReactNativeComponent; })(React.Component); - })(findNodeHandle, findHostInstance$1), + })(findNodeHandle, findHostInstance), findNodeHandle: findNodeHandle, render: function(element, containerTag, callback) { var root = roots.get(containerTag); @@ -6612,7 +6609,7 @@ var roots = new Map(), TextInputState.blurTextInput(findNodeHandle(this)); } }; - })(findNodeHandle, findHostInstance$1) + })(findNodeHandle, findHostInstance) } }; (function(devToolsConfig) { diff --git a/Libraries/Renderer/oss/ReactNativeRenderer-dev.js b/Libraries/Renderer/oss/ReactNativeRenderer-dev.js index e2929210ac6f1d..329aabccc5d1ed 100644 --- a/Libraries/Renderer/oss/ReactNativeRenderer-dev.js +++ b/Libraries/Renderer/oss/ReactNativeRenderer-dev.js @@ -2441,14 +2441,8 @@ var ResponderEventPlugin = { } }; -var customBubblingEventTypes$1 = - ReactNativeViewConfigRegistry.customBubblingEventTypes; -var customDirectEventTypes$1 = - ReactNativeViewConfigRegistry.customDirectEventTypes; -var eventTypes$2 = ReactNativeViewConfigRegistry.eventTypes; - var ReactNativeBridgeEventPlugin = { - eventTypes: eventTypes$2, + eventTypes: ReactNativeViewConfigRegistry.eventTypes, /** * @see {EventPluginHub.extractEvents} @@ -2463,8 +2457,10 @@ var ReactNativeBridgeEventPlugin = { // Probably a node belonging to another renderer's tree. return null; } - var bubbleDispatchConfig = customBubblingEventTypes$1[topLevelType]; - var directDispatchConfig = customDirectEventTypes$1[topLevelType]; + var bubbleDispatchConfig = + ReactNativeViewConfigRegistry.customBubblingEventTypes[topLevelType]; + var directDispatchConfig = + ReactNativeViewConfigRegistry.customDirectEventTypes[topLevelType]; invariant( bubbleDispatchConfig || directDispatchConfig, 'Unsupported top level event type "%s" dispatched', @@ -2786,14 +2782,6 @@ function receiveTouches(eventTopLevelType, touches, changedIndices) { } } -var ReactNativeEventEmitter = Object.freeze({ - getListener: getListener, - registrationNames: registrationNameModules, - _receiveRootNodeIDEvent: _receiveRootNodeIDEvent, - receiveEvent: receiveEvent, - receiveTouches: receiveTouches -}); - // Module provided by RN: var ReactNativeGlobalResponderHandler = { onChange: function(from, to, blockNativeResponder) { @@ -2810,7 +2798,10 @@ var ReactNativeGlobalResponderHandler = { /** * Register the event emitter with the native bridge */ -RCTEventEmitter.register(ReactNativeEventEmitter); +RCTEventEmitter.register({ + receiveEvent: receiveEvent, + receiveTouches: receiveTouches +}); setComponentTree( getFiberCurrentPropsFromNode$1, @@ -3885,7 +3876,7 @@ var createHiddenTextInstance = shim; function shim$1() { invariant( false, - "The current renderer does not support hyration. " + + "The current renderer does not support hydration. " + "This error is likely caused by a bug in React. " + "Please file an issue." ); @@ -4082,11 +4073,11 @@ function resetAfterCommit(containerInfo) { // Noop } -var now = now$1; +var now$$1 = now$1; var isPrimaryRenderer = true; -var scheduleDeferredCallback = scheduleDeferredCallback$1; -var cancelDeferredCallback = cancelDeferredCallback$1; -var shouldYield = shouldYield$1; +var scheduleDeferredCallback$$1 = scheduleDeferredCallback$1; +var cancelDeferredCallback$$1 = cancelDeferredCallback$1; +var shouldYield$$1 = shouldYield$1; var scheduleTimeout = setTimeout; var cancelTimeout = clearTimeout; @@ -4331,13 +4322,14 @@ var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame; function describeFiber(fiber) { switch (fiber.tag) { - case IndeterminateComponent: - case LazyComponent: - case FunctionComponent: - case ClassComponent: - case HostComponent: - case Mode: - case SuspenseComponent: + case HostRoot: + case HostPortal: + case HostText: + case Fragment: + case ContextProvider: + case ContextConsumer: + return ""; + default: var owner = fiber._debugOwner; var source = fiber._debugSource; var name = getComponentName(fiber.type); @@ -4346,8 +4338,6 @@ function describeFiber(fiber) { ownerName = getComponentName(owner.type); } return describeComponentFrame(name, source, ownerName); - default: - return ""; } } @@ -5434,6 +5424,23 @@ function FiberNode(tag, pendingProps, key, mode) { this.alternate = null; if (enableProfilerTimer) { + // Note: The following is done to avoid a v8 deopt. + // + // It is important to initialize the fields below with doubles. + // Otherwise Fibers will deopt and end up having separate shapes when + // doubles are later assigned to fields that initially contained smis. + // This is a bug in v8 having something to do with Object.preventExtension(). + // + // Learn more about this deopt here: + // https://github.com/facebook/react/issues/14365 + // https://bugs.chromium.org/p/v8/issues/detail?id=8538 + this.actualDuration = Number.NaN; + this.actualStartTime = Number.NaN; + this.selfBaseDuration = Number.NaN; + this.treeBaseDuration = Number.NaN; + + // It's okay to replace the initial doubles with smis after initialization. + // This simplifies other profiler code and doesn't trigger the deopt. this.actualDuration = 0; this.actualStartTime = -1; this.selfBaseDuration = 0; @@ -7646,7 +7653,7 @@ function cloneHook(hook) { return { memoizedState: hook.memoizedState, - baseState: hook.memoizedState, + baseState: hook.baseState, queue: hook.queue, baseUpdate: hook.baseUpdate, @@ -7897,15 +7904,6 @@ function useRef(initialValue) { return ref; } -function useMutationEffect(create, inputs) { - useEffectImpl( - Snapshot | Update, - UnmountSnapshot | MountMutation, - create, - inputs - ); -} - function useLayoutEffect(create, inputs) { useEffectImpl(Update, UnmountMutation | MountLayout, create, inputs); } @@ -7953,28 +7951,23 @@ function useImperativeMethods(ref, create, inputs) { // TODO: I've implemented this on top of useEffect because it's almost the // same thing, and it would require an equal amount of code. It doesn't seem // like a common enough use case to justify the additional size. - useEffectImpl( - Update, - UnmountMutation | MountLayout, - function() { - if (typeof ref === "function") { - var refCallback = ref; - var _inst = create(); - refCallback(_inst); - return function() { - return refCallback(null); - }; - } else if (ref !== null && ref !== undefined) { - var refObject = ref; - var _inst2 = create(); - refObject.current = _inst2; - return function() { - refObject.current = null; - }; - } - }, - nextInputs - ); + useLayoutEffect(function() { + if (typeof ref === "function") { + var refCallback = ref; + var _inst = create(); + refCallback(_inst); + return function() { + return refCallback(null); + }; + } else if (ref !== null && ref !== undefined) { + var refObject = ref; + var _inst2 = create(); + refObject.current = _inst2; + return function() { + refObject.current = null; + }; + } + }, nextInputs); } function useCallback(callback, inputs) { @@ -8166,7 +8159,7 @@ function recordCommitTime() { if (!enableProfilerTimer) { return; } - commitTime = now(); + commitTime = now$$1(); } function startProfilerTimer(fiber) { @@ -8174,10 +8167,10 @@ function startProfilerTimer(fiber) { return; } - profilerStartTime = now(); + profilerStartTime = now$$1(); if (fiber.actualStartTime < 0) { - fiber.actualStartTime = now(); + fiber.actualStartTime = now$$1(); } } @@ -8194,7 +8187,7 @@ function stopProfilerTimerIfRunningAndRecordDelta(fiber, overrideBaseTime) { } if (profilerStartTime >= 0) { - var elapsedTime = now() - profilerStartTime; + var elapsedTime = now$$1() - profilerStartTime; fiber.actualDuration += elapsedTime; if (overrideBaseTime) { fiber.selfBaseDuration = elapsedTime; @@ -11078,12 +11071,14 @@ var didWarnAboutBadClass = void 0; var didWarnAboutContextTypeOnFunctionComponent = void 0; var didWarnAboutGetDerivedStateOnFunctionComponent = void 0; var didWarnAboutFunctionRefs = void 0; +var didWarnAboutReassigningProps = void 0; { didWarnAboutBadClass = {}; didWarnAboutContextTypeOnFunctionComponent = {}; didWarnAboutGetDerivedStateOnFunctionComponent = {}; didWarnAboutFunctionRefs = {}; + didWarnAboutReassigningProps = false; } function reconcileChildren( @@ -11158,6 +11153,23 @@ function updateForwardRef( nextProps, renderExpirationTime ) { + { + if (workInProgress.type !== workInProgress.elementType) { + // Lazy component props can't be validated in createElement + // because they're only guaranteed to be resolved here. + var innerPropTypes = Component.propTypes; + if (innerPropTypes) { + checkPropTypes( + innerPropTypes, + nextProps, // Resolved props + "prop", + getComponentName(Component), + getCurrentFiberStackInDev + ); + } + } + } + var render = Component.render; var ref = workInProgress.ref; @@ -11194,12 +11206,20 @@ function updateMemoComponent( ) { if (current$$1 === null) { var type = Component.type; - if (isSimpleFunctionComponent(type) && Component.compare === null) { + if ( + isSimpleFunctionComponent(type) && + Component.compare === null && + // SimpleMemoComponent codepath doesn't resolve outer props either. + Component.defaultProps === undefined + ) { // If this is a plain function component without default props, // and with only the default shallow comparison, we upgrade it // to a SimpleMemoComponent to allow fast path updates. workInProgress.tag = SimpleMemoComponent; workInProgress.type = type; + { + validateFunctionComponentInDev(workInProgress, type); + } return updateSimpleMemoComponent( current$$1, workInProgress, @@ -11209,6 +11229,20 @@ function updateMemoComponent( renderExpirationTime ); } + { + var innerPropTypes = type.propTypes; + if (innerPropTypes) { + // Inner memo component props aren't currently validated in createElement. + // We could move it there, but we'd still need this for lazy code path. + checkPropTypes( + innerPropTypes, + nextProps, // Resolved props + "prop", + getComponentName(type), + getCurrentFiberStackInDev + ); + } + } var child = createFiberFromTypeAndProps( Component.type, null, @@ -11222,6 +11256,21 @@ function updateMemoComponent( workInProgress.child = child; return child; } + { + var _type = Component.type; + var _innerPropTypes = _type.propTypes; + if (_innerPropTypes) { + // Inner memo component props aren't currently validated in createElement. + // We could move it there, but we'd still need this for lazy code path. + checkPropTypes( + _innerPropTypes, + nextProps, // Resolved props + "prop", + getComponentName(_type), + getCurrentFiberStackInDev + ); + } + } var currentChild = current$$1.child; // This is always exactly one child if (updateExpirationTime < renderExpirationTime) { // This will be the props with resolved defaultProps, @@ -11262,6 +11311,30 @@ function updateSimpleMemoComponent( updateExpirationTime, renderExpirationTime ) { + { + if (workInProgress.type !== workInProgress.elementType) { + // Lazy component props can't be validated in createElement + // because they're only guaranteed to be resolved here. + var outerMemoType = workInProgress.elementType; + if (outerMemoType.$$typeof === REACT_LAZY_TYPE) { + // We warn when you define propTypes on lazy() + // so let's just skip over it to find memo() outer wrapper. + // Inner props for memo are validated later. + outerMemoType = refineResolvedLazyComponent(outerMemoType); + } + var outerPropTypes = outerMemoType && outerMemoType.propTypes; + if (outerPropTypes) { + checkPropTypes( + outerPropTypes, + nextProps, // Resolved (SimpleMemoComponent has no defaultProps) + "prop", + getComponentName(outerMemoType), + getCurrentFiberStackInDev + ); + } + // Inner propTypes will be validated in the function component path. + } + } if (current$$1 !== null && updateExpirationTime < renderExpirationTime) { var prevProps = current$$1.memoizedProps; if ( @@ -11339,6 +11412,23 @@ function updateFunctionComponent( nextProps, renderExpirationTime ) { + { + if (workInProgress.type !== workInProgress.elementType) { + // Lazy component props can't be validated in createElement + // because they're only guaranteed to be resolved here. + var innerPropTypes = Component.propTypes; + if (innerPropTypes) { + checkPropTypes( + innerPropTypes, + nextProps, // Resolved props + "prop", + getComponentName(Component), + getCurrentFiberStackInDev + ); + } + } + } + var unmaskedContext = getUnmaskedContext(workInProgress, Component, true); var context = getMaskedContext(workInProgress, unmaskedContext); @@ -11371,6 +11461,23 @@ function updateClassComponent( nextProps, renderExpirationTime ) { + { + if (workInProgress.type !== workInProgress.elementType) { + // Lazy component props can't be validated in createElement + // because they're only guaranteed to be resolved here. + var innerPropTypes = Component.propTypes; + if (innerPropTypes) { + checkPropTypes( + innerPropTypes, + nextProps, // Resolved props + "prop", + getComponentName(Component), + getCurrentFiberStackInDev + ); + } + } + } + // Push context providers early to prevent context stack mismatches. // During mounting we don't know the child context yet as the instance doesn't exist. // We will invalidate the child context in finishClassComponent() right after rendering. @@ -11427,7 +11534,7 @@ function updateClassComponent( renderExpirationTime ); } - return finishClassComponent( + var nextUnitOfWork = finishClassComponent( current$$1, workInProgress, Component, @@ -11435,6 +11542,21 @@ function updateClassComponent( hasContext, renderExpirationTime ); + { + var inst = workInProgress.stateNode; + if (inst.props !== nextProps) { + !didWarnAboutReassigningProps + ? warning$1( + false, + "It looks like %s is reassigning its own `this.props` while rendering. " + + "This is not supported and can lead to confusing bugs.", + getComponentName(workInProgress.type) || "a component" + ) + : void 0; + didWarnAboutReassigningProps = true; + } + } + return nextUnitOfWork; } function finishClassComponent( @@ -11737,6 +11859,20 @@ function mountLazyComponent( break; } case MemoComponent: { + { + if (workInProgress.type !== workInProgress.elementType) { + var outerPropTypes = Component.propTypes; + if (outerPropTypes) { + checkPropTypes( + outerPropTypes, + resolvedProps, // Resolved for outer only + "prop", + getComponentName(Component), + getCurrentFiberStackInDev + ); + } + } + } child = updateMemoComponent( null, workInProgress, @@ -11748,14 +11884,25 @@ function mountLazyComponent( break; } default: { - // This message intentionally doesn't metion ForwardRef or MemoComponent + var hint = ""; + { + if ( + Component !== null && + typeof Component === "object" && + Component.$$typeof === REACT_LAZY_TYPE + ) { + hint = " Did you wrap a component in React.lazy() more than once?"; + } + } + // This message intentionally doesn't mention ForwardRef or MemoComponent // because the fact that it's a separate type of work is an // implementation detail. invariant( false, "Element type is invalid. Received a promise that resolves to: %s. " + - "Promise elements must resolve to a class or function.", - Component + "Lazy element type must resolve to a class or function.%s", + Component, + hint ); } } @@ -11925,70 +12072,74 @@ function mountIndeterminateComponent( // Proceed under the assumption that this is a function component workInProgress.tag = FunctionComponent; value = finishHooks(Component, props, value, context); + reconcileChildren(null, workInProgress, value, renderExpirationTime); { - if (Component) { - !!Component.childContextTypes - ? warningWithoutStack$1( - false, - "%s(...): childContextTypes cannot be defined on a function component.", - Component.displayName || Component.name || "Component" - ) - : void 0; - } - if (workInProgress.ref !== null) { - var info = ""; - var ownerName = getCurrentFiberOwnerNameInDevOrNull(); - if (ownerName) { - info += "\n\nCheck the render method of `" + ownerName + "`."; - } + validateFunctionComponentInDev(workInProgress, Component); + } + return workInProgress.child; + } +} - var warningKey = ownerName || workInProgress._debugID || ""; - var debugSource = workInProgress._debugSource; - if (debugSource) { - warningKey = debugSource.fileName + ":" + debugSource.lineNumber; - } - if (!didWarnAboutFunctionRefs[warningKey]) { - didWarnAboutFunctionRefs[warningKey] = true; - warning$1( - false, - "Function components cannot be given refs. " + - "Attempts to access this ref will fail.%s", - info - ); - } - } +function validateFunctionComponentInDev(workInProgress, Component) { + if (Component) { + !!Component.childContextTypes + ? warningWithoutStack$1( + false, + "%s(...): childContextTypes cannot be defined on a function component.", + Component.displayName || Component.name || "Component" + ) + : void 0; + } + if (workInProgress.ref !== null) { + var info = ""; + var ownerName = getCurrentFiberOwnerNameInDevOrNull(); + if (ownerName) { + info += "\n\nCheck the render method of `" + ownerName + "`."; + } - if (typeof Component.getDerivedStateFromProps === "function") { - var _componentName = getComponentName(Component) || "Unknown"; + var warningKey = ownerName || workInProgress._debugID || ""; + var debugSource = workInProgress._debugSource; + if (debugSource) { + warningKey = debugSource.fileName + ":" + debugSource.lineNumber; + } + if (!didWarnAboutFunctionRefs[warningKey]) { + didWarnAboutFunctionRefs[warningKey] = true; + warning$1( + false, + "Function components cannot be given refs. " + + "Attempts to access this ref will fail.%s", + info + ); + } + } - if (!didWarnAboutGetDerivedStateOnFunctionComponent[_componentName]) { - warningWithoutStack$1( - false, - "%s: Function components do not support getDerivedStateFromProps.", - _componentName - ); - didWarnAboutGetDerivedStateOnFunctionComponent[_componentName] = true; - } - } + if (typeof Component.getDerivedStateFromProps === "function") { + var componentName = getComponentName(Component) || "Unknown"; - if ( - typeof Component.contextType === "object" && - Component.contextType !== null - ) { - var _componentName2 = getComponentName(Component) || "Unknown"; + if (!didWarnAboutGetDerivedStateOnFunctionComponent[componentName]) { + warningWithoutStack$1( + false, + "%s: Function components do not support getDerivedStateFromProps.", + componentName + ); + didWarnAboutGetDerivedStateOnFunctionComponent[componentName] = true; + } + } - if (!didWarnAboutContextTypeOnFunctionComponent[_componentName2]) { - warningWithoutStack$1( - false, - "%s: Function components do not support contextType.", - _componentName2 - ); - didWarnAboutContextTypeOnFunctionComponent[_componentName2] = true; - } - } + if ( + typeof Component.contextType === "object" && + Component.contextType !== null + ) { + var _componentName = getComponentName(Component) || "Unknown"; + + if (!didWarnAboutContextTypeOnFunctionComponent[_componentName]) { + warningWithoutStack$1( + false, + "%s: Function components do not support contextType.", + _componentName + ); + didWarnAboutContextTypeOnFunctionComponent[_componentName] = true; } - reconcileChildren(null, workInProgress, value, renderExpirationTime); - return workInProgress.child; } } @@ -12113,7 +12264,6 @@ function updateSuspenseComponent( currentPrimaryChildFragment.pendingProps, NoWork ); - _primaryChildFragment.effectTag |= Placement; if ((workInProgress.mode & ConcurrentMode) === NoContext) { // Outside of concurrent mode, we commit the effects from the @@ -12147,7 +12297,6 @@ function updateSuspenseComponent( _nextFallbackChildren, currentFallbackChildFragment.expirationTime )); - _fallbackChildFragment.effectTag |= Placement; child = _primaryChildFragment; _primaryChildFragment.childExpirationTime = NoWork; // Skip the primary children, and continue working on the @@ -12177,6 +12326,7 @@ function updateSuspenseComponent( } } else { // The current tree has not already timed out. That means the primary + // children are not wrapped in a fragment fiber. var _currentPrimaryChild = current$$1.child; if (nextDidTimeout) { // Timed out. Wrap the children in a fragment fiber to keep them @@ -12190,10 +12340,12 @@ function updateSuspenseComponent( NoWork, null ); - - _primaryChildFragment2.effectTag |= Placement; _primaryChildFragment2.child = _currentPrimaryChild; - _currentPrimaryChild.return = _primaryChildFragment2; + + // Even though we're creating a new fiber, there are no new children, + // because we're reusing an already mounted tree. So we don't need to + // schedule a placement. + // primaryChildFragment.effectTag |= Placement; if ((workInProgress.mode & ConcurrentMode) === NoContext) { // Outside of concurrent mode, we commit the effects from the @@ -12649,13 +12801,29 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { renderExpirationTime ); case MemoComponent: { - var _type = workInProgress.type; + var _type2 = workInProgress.type; var _unresolvedProps3 = workInProgress.pendingProps; - var _resolvedProps3 = resolveDefaultProps(_type.type, _unresolvedProps3); + // Resolve outer props first, then resolve inner props. + var _resolvedProps3 = resolveDefaultProps(_type2, _unresolvedProps3); + { + if (workInProgress.type !== workInProgress.elementType) { + var outerPropTypes = _type2.propTypes; + if (outerPropTypes) { + checkPropTypes( + outerPropTypes, + _resolvedProps3, // Resolved for outer only + "prop", + getComponentName(_type2), + getCurrentFiberStackInDev + ); + } + } + } + _resolvedProps3 = resolveDefaultProps(_type2.type, _resolvedProps3); return updateMemoComponent( current$$1, workInProgress, - _type, + _type2, _resolvedProps3, updateExpirationTime, renderExpirationTime @@ -13302,12 +13470,16 @@ function completeWork(current, workInProgress, renderExpirationTime) { // TODO: Would it be better to store the fallback fragment on var currentFallbackChild = current.child.sibling; if (currentFallbackChild !== null) { - reconcileChildFibers( - workInProgress, - currentFallbackChild, - null, - renderExpirationTime - ); + // Deletions go at the beginning of the return fiber's effect list + var first = workInProgress.firstEffect; + if (first !== null) { + workInProgress.firstEffect = currentFallbackChild; + currentFallbackChild.nextEffect = first; + } else { + workInProgress.firstEffect = workInProgress.lastEffect = currentFallbackChild; + currentFallbackChild.nextEffect = null; + } + currentFallbackChild.effectTag = Deletion; } } @@ -13605,21 +13777,30 @@ function commitBeforeMutationLifeCycles(current$$1, finishedWork) { // but instead we rely on them being set during last render. // TODO: revisit this when we implement resuming. { - if (finishedWork.type === finishedWork.elementType) { + if ( + finishedWork.type === finishedWork.elementType && + !didWarnAboutReassigningProps + ) { !(instance.props === finishedWork.memoizedProps) ? warning$1( false, - "Expected instance props to match memoized props before " + - "getSnapshotBeforeUpdate. This is likely due to a bug in React. " + - "Please file an issue." + "Expected %s props to match memoized props before " + + "getSnapshotBeforeUpdate. " + + "This might either be because of a bug in React, or because " + + "a component reassigns its own `this.props`. " + + "Please file an issue.", + getComponentName(finishedWork.type) || "instance" ) : void 0; !(instance.state === finishedWork.memoizedState) ? warning$1( false, - "Expected instance state to match memoized state before " + - "getSnapshotBeforeUpdate. This is likely due to a bug in React. " + - "Please file an issue." + "Expected %s state to match memoized state before " + + "getSnapshotBeforeUpdate. " + + "This might either be because of a bug in React, or because " + + "a component reassigns its own `this.props`. " + + "Please file an issue.", + getComponentName(finishedWork.type) || "instance" ) : void 0; } @@ -13695,9 +13876,17 @@ function commitHookEffectList(unmountTag, mountTag, finishedWork) { "useEffect function must return a cleanup function or " + "nothing.%s%s", typeof _destroy.then === "function" - ? " Promises and useEffect(async () => ...) are not " + - "supported, but you can call an async function inside an " + - "effect." + ? "\n\nIt looks like you wrote useEffect(async () => ...) or returned a Promise. " + + "Instead, you may write an async function separately " + + "and then call it from inside the effect:\n\n" + + "async function fetchComment(commentId) {\n" + + " // You can await here\n" + + "}\n\n" + + "useEffect(() => {\n" + + " fetchComment(commentId);\n" + + "}, [commentId]);\n\n" + + "In the future, React will provide a more idiomatic solution for data fetching " + + "that doesn't involve writing effects manually." : "", getStackByFiberInDevAndProd(finishedWork) ); @@ -13739,21 +13928,30 @@ function commitLifeCycles( // but instead we rely on them being set during last render. // TODO: revisit this when we implement resuming. { - if (finishedWork.type === finishedWork.elementType) { + if ( + finishedWork.type === finishedWork.elementType && + !didWarnAboutReassigningProps + ) { !(instance.props === finishedWork.memoizedProps) ? warning$1( false, - "Expected instance props to match memoized props before " + - "componentDidMount. This is likely due to a bug in React. " + - "Please file an issue." + "Expected %s props to match memoized props before " + + "componentDidMount. " + + "This might either be because of a bug in React, or because " + + "a component reassigns its own `this.props`. " + + "Please file an issue.", + getComponentName(finishedWork.type) || "instance" ) : void 0; !(instance.state === finishedWork.memoizedState) ? warning$1( false, - "Expected instance state to match memoized state before " + - "componentDidMount. This is likely due to a bug in React. " + - "Please file an issue." + "Expected %s state to match memoized state before " + + "componentDidMount. " + + "This might either be because of a bug in React, or because " + + "a component reassigns its own `this.props`. " + + "Please file an issue.", + getComponentName(finishedWork.type) || "instance" ) : void 0; } @@ -13774,21 +13972,30 @@ function commitLifeCycles( // but instead we rely on them being set during last render. // TODO: revisit this when we implement resuming. { - if (finishedWork.type === finishedWork.elementType) { + if ( + finishedWork.type === finishedWork.elementType && + !didWarnAboutReassigningProps + ) { !(instance.props === finishedWork.memoizedProps) ? warning$1( false, - "Expected instance props to match memoized props before " + - "componentDidUpdate. This is likely due to a bug in React. " + - "Please file an issue." + "Expected %s props to match memoized props before " + + "componentDidUpdate. " + + "This might either be because of a bug in React, or because " + + "a component reassigns its own `this.props`. " + + "Please file an issue.", + getComponentName(finishedWork.type) || "instance" ) : void 0; !(instance.state === finishedWork.memoizedState) ? warning$1( false, - "Expected instance state to match memoized state before " + - "componentDidUpdate. This is likely due to a bug in React. " + - "Please file an issue." + "Expected %s state to match memoized state before " + + "componentDidUpdate. " + + "This might either be because of a bug in React, or because " + + "a component reassigns its own `this.props`. " + + "Please file an issue.", + getComponentName(finishedWork.type) || "instance" ) : void 0; } @@ -13804,21 +14011,30 @@ function commitLifeCycles( var updateQueue = finishedWork.updateQueue; if (updateQueue !== null) { { - if (finishedWork.type === finishedWork.elementType) { + if ( + finishedWork.type === finishedWork.elementType && + !didWarnAboutReassigningProps + ) { !(instance.props === finishedWork.memoizedProps) ? warning$1( false, - "Expected instance props to match memoized props before " + - "processing the update queue. This is likely due to a bug in React. " + - "Please file an issue." + "Expected %s props to match memoized props before " + + "processing the update queue. " + + "This might either be because of a bug in React, or because " + + "a component reassigns its own `this.props`. " + + "Please file an issue.", + getComponentName(finishedWork.type) || "instance" ) : void 0; !(instance.state === finishedWork.memoizedState) ? warning$1( false, - "Expected instance state to match memoized state before " + - "processing the update queue. This is likely due to a bug in React. " + - "Please file an issue." + "Expected %s state to match memoized state before " + + "processing the update queue. " + + "This might either be because of a bug in React, or because " + + "a component reassigns its own `this.props`. " + + "Please file an issue.", + getComponentName(finishedWork.type) || "instance" ) : void 0; } @@ -13940,6 +14156,15 @@ function hideOrUnhideAllChildren(finishedWork, isHidden) { } else { unhideTextInstance(_instance3, node.memoizedProps); } + } else if ( + node.tag === SuspenseComponent && + node.memoizedState !== null + ) { + // Found a nested Suspense component that timed out. Skip over the + var fallbackChildFragment = node.child.sibling; + fallbackChildFragment.return = node; + node = fallbackChildFragment; + continue; } else if (node.child !== null) { node.child.return = node; node = node.child; @@ -14099,9 +14324,14 @@ function detachFiber(current$$1) { // itself will be GC:ed when the parent updates the next time. current$$1.return = null; current$$1.child = null; - if (current$$1.alternate) { - current$$1.alternate.child = null; - current$$1.alternate.return = null; + current$$1.memoizedState = null; + current$$1.updateQueue = null; + var alternate = current$$1.alternate; + if (alternate !== null) { + alternate.return = null; + alternate.child = null; + alternate.memoizedState = null; + alternate.updateQueue = null; } } @@ -14402,6 +14632,8 @@ function commitWork(current$$1, finishedWork) { case ForwardRef: case MemoComponent: case SimpleMemoComponent: { + // Note: We currently never use MountMutation, but useLayout uses + // UnmountMutation. commitHookEffectList(UnmountMutation, MountMutation, finishedWork); return; } @@ -14416,6 +14648,8 @@ function commitWork(current$$1, finishedWork) { case ForwardRef: case MemoComponent: case SimpleMemoComponent: { + // Note: We currently never use MountMutation, but useLayout uses + // UnmountMutation. commitHookEffectList(UnmountMutation, MountMutation, finishedWork); return; } @@ -14673,20 +14907,10 @@ function throwException( if ((_workInProgress.mode & ConcurrentMode) === NoEffect) { _workInProgress.effectTag |= DidCapture; - // Unmount the source fiber's children - var nextChildren = null; - reconcileChildren( - sourceFiber.alternate, - sourceFiber, - nextChildren, - renderExpirationTime - ); - sourceFiber.effectTag &= ~Incomplete; - // We're going to commit this fiber even though it didn't complete. // But we shouldn't call any lifecycle methods or callbacks. Remove // all lifecycle effect tags. - sourceFiber.effectTag &= ~LifecycleEffectMask; + sourceFiber.effectTag &= ~(LifecycleEffectMask | Incomplete); if (sourceFiber.tag === ClassComponent) { var _current = sourceFiber.alternate; @@ -14902,7 +15126,6 @@ var Dispatcher = { useImperativeMethods: useImperativeMethods, useLayoutEffect: useLayoutEffect, useMemo: useMemo, - useMutationEffect: useMutationEffect, useReducer: useReducer, useRef: useRef, useState: useState @@ -14920,12 +15143,12 @@ var warnAboutInvalidUpdates = void 0; if (enableSchedulerTracing) { // Provide explicit error message when production+profiling bundle of e.g. react-dom - // is used with production (non-profiling) bundle of schedule/tracing + // is used with production (non-profiling) bundle of scheduler/tracing invariant( 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/tracing` module with `schedule/tracing-profiling`. " + + "without also replacing the `scheduler/tracing` module with `scheduler/tracing-profiling`. " + "Your bundler might have a setting for aliasing both modules. " + "Learn more at http://fb.me/react-profiling" ); @@ -16422,6 +16645,46 @@ function scheduleWorkToRoot(fiber, expirationTime) { } } + if (enableSchedulerTracing) { + if (root !== null) { + 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 { + pendingInteractionMap.set(expirationTime, new Set(interactions)); + + // Update the pending async work count for the current interactions. + interactions.forEach(function(interaction) { + interaction.__count++; + }); + } + + var subscriber = tracing.__subscriberRef.current; + if (subscriber !== null) { + var threadID = computeThreadID( + expirationTime, + root.interactionThreadID + ); + subscriber.onWorkScheduled(interactions, threadID); + } + } + } + } + return root; +} + +function scheduleWork(fiber, expirationTime) { + var root = scheduleWorkToRoot(fiber, expirationTime); if (root === null) { { switch (fiber.tag) { @@ -16436,49 +16699,6 @@ function scheduleWorkToRoot(fiber, expirationTime) { break; } } - return null; - } - - 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 { - pendingInteractionMap.set(expirationTime, new Set(interactions)); - - // Update the pending async work count for the current interactions. - interactions.forEach(function(interaction) { - interaction.__count++; - }); - } - - var subscriber = tracing.__subscriberRef.current; - if (subscriber !== null) { - var threadID = computeThreadID( - expirationTime, - root.interactionThreadID - ); - subscriber.onWorkScheduled(interactions, threadID); - } - } - } - - return root; -} - -function scheduleWork(fiber, expirationTime) { - var root = scheduleWorkToRoot(fiber, expirationTime); - if (root === null) { return; } @@ -16538,7 +16758,7 @@ var isBatchingInteractiveUpdates = false; var completedBatches = null; -var originalStartTimeMs = now(); +var originalStartTimeMs = now$$1(); var currentRendererTime = msToExpirationTime(originalStartTimeMs); var currentSchedulerTime = currentRendererTime; @@ -16548,7 +16768,7 @@ var nestedUpdateCount = 0; var lastCommittedRootDuringThisBatch = null; function recomputeCurrentRendererTime() { - var currentTimeMs = now() - originalStartTimeMs; + var currentTimeMs = now$$1() - originalStartTimeMs; currentRendererTime = msToExpirationTime(currentTimeMs); } @@ -16562,7 +16782,7 @@ function scheduleCallbackWithExpirationTime(root, expirationTime) { if (callbackID !== null) { // Existing callback has insufficient timeout. Cancel and schedule a // new one. - cancelDeferredCallback(callbackID); + cancelDeferredCallback$$1(callbackID); } } // The request callback timer is already running. Don't start a new one. @@ -16571,10 +16791,12 @@ function scheduleCallbackWithExpirationTime(root, expirationTime) { } callbackExpirationTime = expirationTime; - var currentMs = now() - originalStartTimeMs; + var currentMs = now$$1() - originalStartTimeMs; var expirationTimeMs = expirationTimeToMs(expirationTime); var timeout = expirationTimeMs - currentMs; - callbackID = scheduleDeferredCallback(performAsyncWork, { timeout: timeout }); + callbackID = scheduleDeferredCallback$$1(performAsyncWork, { + timeout: timeout + }); } // For every call to renderRoot, one of onFatal, onComplete, onSuspend, and @@ -16803,7 +17025,7 @@ function shouldYieldToRenderer() { if (didYield) { return true; } - if (shouldYield()) { + if (shouldYield$$1()) { didYield = true; return true; } @@ -17225,7 +17447,7 @@ function updateContainerAtExpirationTime( return scheduleRootUpdate(current$$1, element, expirationTime, callback); } -function findHostInstance$1(component) { +function findHostInstance(component) { var fiber = get$1(component); if (fiber === undefined) { if (typeof component.render === "function") { @@ -17245,7 +17467,7 @@ function findHostInstance$1(component) { return hostFiber.stateNode; } -function findHostInstanceWithWarning$1(component, methodName) { +function findHostInstanceWithWarning(component, methodName) { { var fiber = get$1(component); if (fiber === undefined) { @@ -17300,7 +17522,7 @@ function findHostInstanceWithWarning$1(component, methodName) { } return hostFiber.stateNode; } - return findHostInstance$1(component); + return findHostInstance(component); } function createContainer(containerInfo, isConcurrent, hydrate) { @@ -17885,8 +18107,6 @@ var getInspectorDataForViewTag = void 0; // TODO: direct imports like some-package/src/* are bad. Fix me. // Module provided by RN: var ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner; -var findHostInstance = findHostInstance$1; -var findHostInstanceWithWarning = findHostInstanceWithWarning$1; function findNodeHandle(componentOrHandle) { { diff --git a/Libraries/Renderer/oss/ReactNativeRenderer-prod.js b/Libraries/Renderer/oss/ReactNativeRenderer-prod.js index 8b5e42b7dcee1d..e9268b6d2dd2e5 100644 --- a/Libraries/Renderer/oss/ReactNativeRenderer-prod.js +++ b/Libraries/Renderer/oss/ReactNativeRenderer-prod.js @@ -956,10 +956,6 @@ var eventTypes$1 = { } } }, - customBubblingEventTypes$1 = - ReactNativeViewConfigRegistry.customBubblingEventTypes, - customDirectEventTypes$1 = - ReactNativeViewConfigRegistry.customDirectEventTypes, ReactNativeBridgeEventPlugin = { eventTypes: ReactNativeViewConfigRegistry.eventTypes, extractEvents: function( @@ -969,8 +965,10 @@ var eventTypes$1 = { nativeEventTarget ) { if (null == targetInst) return null; - var bubbleDispatchConfig = customBubblingEventTypes$1[topLevelType], - directDispatchConfig = customDirectEventTypes$1[topLevelType]; + var bubbleDispatchConfig = + ReactNativeViewConfigRegistry.customBubblingEventTypes[topLevelType], + directDispatchConfig = + ReactNativeViewConfigRegistry.customDirectEventTypes[topLevelType]; invariant( bubbleDispatchConfig || directDispatchConfig, 'Unsupported top level event type "%s" dispatched', @@ -1077,9 +1075,6 @@ function _receiveRootNodeIDEvent(rootNodeID, topLevelType, nativeEventParam) { }); } RCTEventEmitter.register({ - getListener: getListener, - registrationNames: registrationNameModules, - _receiveRootNodeIDEvent: _receiveRootNodeIDEvent, receiveEvent: function(rootNodeID, topLevelType, nativeEventParam) { _receiveRootNodeIDEvent(rootNodeID, topLevelType, nativeEventParam); }, @@ -1606,7 +1601,7 @@ function setTimeoutCallback() { function shim$1() { invariant( !1, - "The current renderer does not support hyration. This error is likely caused by a bug in React. Please file an issue." + "The current renderer does not support hydration. This error is likely caused by a bug in React. Please file an issue." ); } var UPDATE_SIGNAL = {}, @@ -1642,17 +1637,19 @@ function getStackByFiberInDevAndProd(workInProgress) { var info = ""; do { a: switch (workInProgress.tag) { - case 2: - case 16: - case 0: - case 1: - case 5: - case 8: - case 13: + case 3: + case 4: + case 6: + case 7: + case 10: + case 9: + var JSCompiler_inline_result = ""; + break a; + default: var owner = workInProgress._debugOwner, source = workInProgress._debugSource, name = getComponentName(workInProgress.type); - var JSCompiler_inline_result = null; + JSCompiler_inline_result = null; owner && (JSCompiler_inline_result = getComponentName(owner.type)); owner = name; name = ""; @@ -1666,9 +1663,6 @@ function getStackByFiberInDevAndProd(workInProgress) { : JSCompiler_inline_result && (name = " (created by " + JSCompiler_inline_result + ")"); JSCompiler_inline_result = "\n in " + (owner || "Unknown") + name; - break a; - default: - JSCompiler_inline_result = ""; } info += JSCompiler_inline_result; workInProgress = workInProgress.return; @@ -3402,7 +3396,8 @@ function updateMemoComponent( "function" === typeof type && !shouldConstruct(type) && void 0 === type.defaultProps && - null === Component.compare + null === Component.compare && + void 0 === Component.defaultProps ) return ( (workInProgress.tag = 15), @@ -3840,7 +3835,6 @@ function updateSuspenseComponent( nextDidTimeout ? ((renderExpirationTime = nextProps.fallback), (nextProps = createWorkInProgress(mode, mode.pendingProps, 0)), - (nextProps.effectTag |= 2), 0 === (workInProgress.mode & 1) && ((nextDidTimeout = null !== workInProgress.memoizedState @@ -3853,7 +3847,6 @@ function updateSuspenseComponent( renderExpirationTime, current$$1.expirationTime )), - (mode.effectTag |= 2), (renderExpirationTime = nextProps), (nextProps.childExpirationTime = 0), (renderExpirationTime.return = mode.return = workInProgress)) @@ -3867,9 +3860,7 @@ function updateSuspenseComponent( nextDidTimeout ? ((nextDidTimeout = nextProps.fallback), (nextProps = createFiberFromFragment(null, mode, 0, null)), - (nextProps.effectTag |= 2), (nextProps.child = current$$1), - (current$$1.return = nextProps), 0 === (workInProgress.mode & 1) && (nextProps.child = null !== workInProgress.memoizedState @@ -4105,8 +4096,9 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { default: invariant( !1, - "Element type is invalid. Received a promise that resolves to: %s. Promise elements must resolve to a class or function.", - current$$1 + "Element type is invalid. Received a promise that resolves to: %s. Lazy element type must resolve to a class or function.%s", + current$$1, + "" ); } return getDerivedStateFromProps; @@ -4413,9 +4405,10 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { return ( (context = workInProgress.type), (hasContext = resolveDefaultProps( - context.type, + context, workInProgress.pendingProps )), + (hasContext = resolveDefaultProps(context.type, hasContext)), updateMemoComponent( current$$1, workInProgress, @@ -4942,7 +4935,12 @@ function commitWork(current$$1, finishedWork) { } else { if (6 === newProps.tag) throw Error("Not yet implemented."); - if (null !== newProps.child) { + if (13 === newProps.tag && null !== newProps.memoizedState) { + current$$1 = newProps.child.sibling; + current$$1.return = newProps; + newProps = current$$1; + continue; + } else if (null !== newProps.child) { newProps.child.return = newProps; newProps = newProps.child; continue; @@ -5225,20 +5223,22 @@ function completeUnitOfWork(workInProgress) { break a; } newProps = null !== newProps; - type = null !== current && null !== current.memoizedState; + renderExpirationTime = + null !== current && null !== current.memoizedState; null !== current && !newProps && - type && - ((current = current.child.sibling), - null !== current && - reconcileChildFibers( - current$$1, - current, - null, - renderExpirationTime - )); + renderExpirationTime && + ((type = current.child.sibling), + null !== type && + ((current = current$$1.firstEffect), + null !== current + ? ((current$$1.firstEffect = type), + (type.nextEffect = current)) + : ((current$$1.firstEffect = current$$1.lastEffect = type), + (type.nextEffect = null)), + (type.effectTag = 8))); if ( - newProps !== type || + newProps !== renderExpirationTime || (0 === (current$$1.effectTag & 1) && newProps) ) current$$1.effectTag |= 4; @@ -5432,14 +5432,7 @@ function renderRoot(root$jscomp$0, isYieldy) { thenable.then(returnFiber$jscomp$0, returnFiber$jscomp$0); if (0 === (value.mode & 1)) { value.effectTag |= 64; - reconcileChildren( - sourceFiber$jscomp$0.alternate, - sourceFiber$jscomp$0, - null, - returnFiber - ); - sourceFiber$jscomp$0.effectTag &= -1025; - sourceFiber$jscomp$0.effectTag &= -933; + sourceFiber$jscomp$0.effectTag &= -1957; 1 === sourceFiber$jscomp$0.tag && null === sourceFiber$jscomp$0.alternate && (sourceFiber$jscomp$0.tag = 17); @@ -5696,7 +5689,7 @@ function scheduleWorkToRoot(fiber, expirationTime) { } node = node.return; } - return null === root ? null : root; + return root; } function scheduleWork(fiber, expirationTime) { fiber = scheduleWorkToRoot(fiber, expirationTime); @@ -6121,13 +6114,18 @@ function completeRoot(root, finishedWork$jscomp$0, expirationTime) { commitWork(nextEffect.alternate, nextEffect); break; case 8: - (prevState = nextEffect), - unmountHostComponents(prevState), - (prevState.return = null), - (prevState.child = null), - prevState.alternate && - ((prevState.alternate.child = null), - (prevState.alternate.return = null)); + prevState = nextEffect; + unmountHostComponents(prevState); + prevState.return = null; + prevState.child = null; + prevState.memoizedState = null; + prevState.updateQueue = null; + var alternate = prevState.alternate; + null !== alternate && + ((alternate.return = null), + (alternate.child = null), + (alternate.memoizedState = null), + (alternate.updateQueue = null)); } nextEffect = nextEffect.nextEffect; } @@ -6151,24 +6149,24 @@ function completeRoot(root, finishedWork$jscomp$0, expirationTime) { var effectTag$jscomp$0 = nextEffect.effectTag; if (effectTag$jscomp$0 & 36) { var current$$1$jscomp$1 = nextEffect.alternate; - current$$1 = nextEffect; - prevProps = currentRef; - switch (current$$1.tag) { + alternate = nextEffect; + current$$1 = currentRef; + switch (alternate.tag) { case 0: case 11: case 15: break; case 1: - var instance$jscomp$0 = current$$1.stateNode; - if (current$$1.effectTag & 4) + var instance$jscomp$0 = alternate.stateNode; + if (alternate.effectTag & 4) if (null === current$$1$jscomp$1) instance$jscomp$0.componentDidMount(); else { var prevProps$jscomp$0 = - current$$1.elementType === current$$1.type + alternate.elementType === alternate.type ? current$$1$jscomp$1.memoizedProps : resolveDefaultProps( - current$$1.type, + alternate.type, current$$1$jscomp$1.memoizedProps ); instance$jscomp$0.componentDidUpdate( @@ -6177,32 +6175,32 @@ function completeRoot(root, finishedWork$jscomp$0, expirationTime) { instance$jscomp$0.__reactInternalSnapshotBeforeUpdate ); } - var updateQueue = current$$1.updateQueue; + var updateQueue = alternate.updateQueue; null !== updateQueue && commitUpdateQueue( - current$$1, + alternate, updateQueue, instance$jscomp$0, - prevProps + current$$1 ); break; case 3: - var _updateQueue = current$$1.updateQueue; + var _updateQueue = alternate.updateQueue; if (null !== _updateQueue) { - prevState = null; - if (null !== current$$1.child) - switch (current$$1.child.tag) { + prevProps = null; + if (null !== alternate.child) + switch (alternate.child.tag) { case 5: - prevState = current$$1.child.stateNode; + prevProps = alternate.child.stateNode; break; case 1: - prevState = current$$1.child.stateNode; + prevProps = alternate.child.stateNode; } commitUpdateQueue( - current$$1, + alternate, _updateQueue, - prevState, - prevProps + prevProps, + current$$1 ); } break; @@ -6276,7 +6274,7 @@ function onUncaughtError(error) { nextFlushedRoot.expirationTime = 0; hasUnhandledError || ((hasUnhandledError = !0), (unhandledError = error)); } -function findHostInstance$1(component) { +function findHostInstance(component) { var fiber = component._reactInternalFiber; void 0 === fiber && ("function" === typeof component.render @@ -6389,7 +6387,7 @@ function findNodeHandle(componentOrHandle) { if (componentOrHandle._nativeTag) return componentOrHandle._nativeTag; if (componentOrHandle.canonical && componentOrHandle.canonical._nativeTag) return componentOrHandle.canonical._nativeTag; - componentOrHandle = findHostInstance$1(componentOrHandle); + componentOrHandle = findHostInstance(componentOrHandle); return null == componentOrHandle ? componentOrHandle : componentOrHandle.canonical @@ -6485,7 +6483,7 @@ var roots = new Map(), }; return ReactNativeComponent; })(React.Component); - })(findNodeHandle, findHostInstance$1), + })(findNodeHandle, findHostInstance), findNodeHandle: findNodeHandle, render: function(element, containerTag, callback) { var root = roots.get(containerTag); @@ -6598,7 +6596,7 @@ var roots = new Map(), TextInputState.blurTextInput(findNodeHandle(this)); } }; - })(findNodeHandle, findHostInstance$1), + })(findNodeHandle, findHostInstance), computeComponentStackForErrorReporting: function(reactTag) { return (reactTag = getInstanceFromTag(reactTag)) ? getStackByFiberInDevAndProd(reactTag) diff --git a/Libraries/Renderer/oss/ReactNativeRenderer-profiling.js b/Libraries/Renderer/oss/ReactNativeRenderer-profiling.js index 7a8ebe32ee53c9..4d323e348dd55e 100644 --- a/Libraries/Renderer/oss/ReactNativeRenderer-profiling.js +++ b/Libraries/Renderer/oss/ReactNativeRenderer-profiling.js @@ -957,10 +957,6 @@ var eventTypes$1 = { } } }, - customBubblingEventTypes$1 = - ReactNativeViewConfigRegistry.customBubblingEventTypes, - customDirectEventTypes$1 = - ReactNativeViewConfigRegistry.customDirectEventTypes, ReactNativeBridgeEventPlugin = { eventTypes: ReactNativeViewConfigRegistry.eventTypes, extractEvents: function( @@ -970,8 +966,10 @@ var eventTypes$1 = { nativeEventTarget ) { if (null == targetInst) return null; - var bubbleDispatchConfig = customBubblingEventTypes$1[topLevelType], - directDispatchConfig = customDirectEventTypes$1[topLevelType]; + var bubbleDispatchConfig = + ReactNativeViewConfigRegistry.customBubblingEventTypes[topLevelType], + directDispatchConfig = + ReactNativeViewConfigRegistry.customDirectEventTypes[topLevelType]; invariant( bubbleDispatchConfig || directDispatchConfig, 'Unsupported top level event type "%s" dispatched', @@ -1078,9 +1076,6 @@ function _receiveRootNodeIDEvent(rootNodeID, topLevelType, nativeEventParam) { }); } RCTEventEmitter.register({ - getListener: getListener, - registrationNames: registrationNameModules, - _receiveRootNodeIDEvent: _receiveRootNodeIDEvent, receiveEvent: function(rootNodeID, topLevelType, nativeEventParam) { _receiveRootNodeIDEvent(rootNodeID, topLevelType, nativeEventParam); }, @@ -1607,7 +1602,7 @@ function setTimeoutCallback() { function shim$1() { invariant( !1, - "The current renderer does not support hyration. This error is likely caused by a bug in React. Please file an issue." + "The current renderer does not support hydration. This error is likely caused by a bug in React. Please file an issue." ); } var UPDATE_SIGNAL = {}, @@ -1643,17 +1638,19 @@ function getStackByFiberInDevAndProd(workInProgress) { var info = ""; do { a: switch (workInProgress.tag) { - case 2: - case 16: - case 0: - case 1: - case 5: - case 8: - case 13: + case 3: + case 4: + case 6: + case 7: + case 10: + case 9: + var JSCompiler_inline_result = ""; + break a; + default: var owner = workInProgress._debugOwner, source = workInProgress._debugSource, name = getComponentName(workInProgress.type); - var JSCompiler_inline_result = null; + JSCompiler_inline_result = null; owner && (JSCompiler_inline_result = getComponentName(owner.type)); owner = name; name = ""; @@ -1667,9 +1664,6 @@ function getStackByFiberInDevAndProd(workInProgress) { : JSCompiler_inline_result && (name = " (created by " + JSCompiler_inline_result + ")"); JSCompiler_inline_result = "\n in " + (owner || "Unknown") + name; - break a; - default: - JSCompiler_inline_result = ""; } info += JSCompiler_inline_result; workInProgress = workInProgress.return; @@ -3460,7 +3454,8 @@ function updateMemoComponent( "function" === typeof type && !shouldConstruct(type) && void 0 === type.defaultProps && - null === Component.compare + null === Component.compare && + void 0 === Component.defaultProps ) return ( (workInProgress.tag = 15), @@ -3908,7 +3903,6 @@ function updateSuspenseComponent( current$$1.pendingProps, 0 ); - renderExpirationTime.effectTag |= 2; 0 === (workInProgress.mode & 1) && ((nextDidTimeout = null !== workInProgress.memoizedState @@ -3928,7 +3922,6 @@ function updateSuspenseComponent( nextProps, mode.expirationTime ); - nextProps.effectTag |= 2; mode = renderExpirationTime; renderExpirationTime.childExpirationTime = 0; renderExpirationTime = nextProps; @@ -3943,9 +3936,7 @@ function updateSuspenseComponent( else if (((current$$1 = current$$1.child), nextDidTimeout)) { nextDidTimeout = nextProps.fallback; nextProps = createFiberFromFragment(null, mode, 0, null); - nextProps.effectTag |= 2; nextProps.child = current$$1; - current$$1.return = nextProps; 0 === (workInProgress.mode & 1) && (nextProps.child = null !== workInProgress.memoizedState @@ -4193,8 +4184,9 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { default: invariant( !1, - "Element type is invalid. Received a promise that resolves to: %s. Promise elements must resolve to a class or function.", - current$$1 + "Element type is invalid. Received a promise that resolves to: %s. Lazy element type must resolve to a class or function.%s", + current$$1, + "" ); } return getDerivedStateFromProps; @@ -4502,9 +4494,10 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { return ( (context = workInProgress.type), (hasContext = resolveDefaultProps( - context.type, + context, workInProgress.pendingProps )), + (hasContext = resolveDefaultProps(context.type, hasContext)), updateMemoComponent( current$$1, workInProgress, @@ -5031,7 +5024,12 @@ function commitWork(current$$1, finishedWork) { } else { if (6 === newProps.tag) throw Error("Not yet implemented."); - if (null !== newProps.child) { + if (13 === newProps.tag && null !== newProps.memoizedState) { + current$$1 = newProps.child.sibling; + current$$1.return = newProps; + newProps = current$$1; + continue; + } else if (null !== newProps.child) { newProps.child.return = newProps; newProps = newProps.child; continue; @@ -5149,14 +5147,7 @@ function throwException( thenable.then(returnFiber, returnFiber); if (0 === (value.mode & 1)) { value.effectTag |= 64; - reconcileChildren( - sourceFiber.alternate, - sourceFiber, - null, - renderExpirationTime - ); - sourceFiber.effectTag &= -1025; - sourceFiber.effectTag &= -933; + sourceFiber.effectTag &= -1957; 1 === sourceFiber.tag && null === sourceFiber.alternate && (sourceFiber.tag = 17); @@ -5276,7 +5267,7 @@ var DispatcherWithoutHooks = { readContext: readContext }, invariant( 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" + "It is not supported to run the profiling version of a renderer (for example, `react-dom/profiling`) without also replacing the `scheduler/tracing` module with `scheduler/tracing-profiling`. Your bundler might have a setting for aliasing both modules. Learn more at http://fb.me/react-profiling" ); var isWorking = !1, nextUnitOfWork = null, @@ -5356,9 +5347,14 @@ function commitAllHostEffects() { unmountHostComponents(effectTag), (effectTag.return = null), (effectTag.child = null), - effectTag.alternate && - ((effectTag.alternate.child = null), - (effectTag.alternate.return = null)); + (effectTag.memoizedState = null), + (effectTag.updateQueue = null), + (effectTag = effectTag.alternate), + null !== effectTag && + ((effectTag.return = null), + (effectTag.child = null), + (effectTag.memoizedState = null), + (effectTag.updateQueue = null)); } nextEffect = nextEffect.nextEffect; } @@ -5769,19 +5765,24 @@ function completeUnitOfWork(workInProgress) { break a; } fiber = null !== fiber; - type = null !== current && null !== current.memoizedState; + renderExpirationTime = + null !== current && null !== current.memoizedState; null !== current && !fiber && - type && - ((current = current.child.sibling), - null !== current && - reconcileChildFibers( - current$$1, - current, - null, - renderExpirationTime - )); - if (fiber !== type || (0 === (current$$1.effectTag & 1) && fiber)) + renderExpirationTime && + ((type = current.child.sibling), + null !== type && + ((current = current$$1.firstEffect), + null !== current + ? ((current$$1.firstEffect = type), + (type.nextEffect = current)) + : ((current$$1.firstEffect = current$$1.lastEffect = type), + (type.nextEffect = null)), + (type.effectTag = 8))); + if ( + fiber !== renderExpirationTime || + (0 === (current$$1.effectTag & 1) && fiber) + ) current$$1.effectTag |= 4; break; case 7: @@ -6147,9 +6148,10 @@ function scheduleWorkToRoot(fiber, expirationTime) { } node = node.return; } - if (null === root) return null; - fiber = tracing.__interactionsRef.current; - if (0 < fiber.size) { + if ( + null !== root && + ((fiber = tracing.__interactionsRef.current), 0 < fiber.size) + ) { alternate = root.pendingInteractionMap; var pendingInteractions = alternate.get(expirationTime); null != pendingInteractions @@ -6478,7 +6480,7 @@ function onUncaughtError(error) { nextFlushedRoot.expirationTime = 0; hasUnhandledError || ((hasUnhandledError = !0), (unhandledError = error)); } -function findHostInstance$1(component) { +function findHostInstance(component) { var fiber = component._reactInternalFiber; void 0 === fiber && ("function" === typeof component.render @@ -6591,7 +6593,7 @@ function findNodeHandle(componentOrHandle) { if (componentOrHandle._nativeTag) return componentOrHandle._nativeTag; if (componentOrHandle.canonical && componentOrHandle.canonical._nativeTag) return componentOrHandle.canonical._nativeTag; - componentOrHandle = findHostInstance$1(componentOrHandle); + componentOrHandle = findHostInstance(componentOrHandle); return null == componentOrHandle ? componentOrHandle : componentOrHandle.canonical @@ -6687,7 +6689,7 @@ var roots = new Map(), }; return ReactNativeComponent; })(React.Component); - })(findNodeHandle, findHostInstance$1), + })(findNodeHandle, findHostInstance), findNodeHandle: findNodeHandle, render: function(element, containerTag, callback) { var root = roots.get(containerTag); @@ -6805,7 +6807,7 @@ var roots = new Map(), TextInputState.blurTextInput(findNodeHandle(this)); } }; - })(findNodeHandle, findHostInstance$1), + })(findNodeHandle, findHostInstance), computeComponentStackForErrorReporting: function(reactTag) { return (reactTag = getInstanceFromTag(reactTag)) ? getStackByFiberInDevAndProd(reactTag) diff --git a/Libraries/Renderer/shims/ReactTypes.js b/Libraries/Renderer/shims/ReactTypes.js index 080ade12b807b0..f09207928ceaff 100644 --- a/Libraries/Renderer/shims/ReactTypes.js +++ b/Libraries/Renderer/shims/ReactTypes.js @@ -59,6 +59,7 @@ export type ReactContext = { _currentValue: T, _currentValue2: T, + _threadCount: number, // DEV only _currentRenderer?: Object | null, diff --git a/package.json b/package.json index daf67ec4ca8d29..b76a31cf896e73 100644 --- a/package.json +++ b/package.json @@ -146,7 +146,7 @@ "react-native": "local-cli/wrong-react-native.js" }, "peerDependencies": { - "react": "16.6.1" + "react": "16.6.3" }, "dependencies": { "@babel/runtime": "^7.0.0", @@ -222,9 +222,9 @@ "jest": "24.0.0-alpha.4", "jest-junit": "5.1.0", "prettier": "1.13.6", - "react": "16.6.1", + "react": "16.6.3", "react-native-dummy": "0.1.0", - "react-test-renderer": "16.6.1", + "react-test-renderer": "16.6.3", "shelljs": "^0.7.8" }, "detox": { diff --git a/yarn.lock b/yarn.lock index 3fb8ea6160b168..012b6b492d1aac 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2423,12 +2423,13 @@ fbjs-scripts@^1.0.0: semver "^5.1.0" through2 "^2.0.0" -fbjs@^0.8.9: - version "0.8.17" - resolved "https://registry.yarnpkg.com/fbjs/-/fbjs-0.8.17.tgz#c4d598ead6949112653d6588b01a5cdcd9f90fdd" - integrity sha1-xNWY6taUkRJlPWWIsBpc3Nn5D90= +fbjs@1.0.0, fbjs@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/fbjs/-/fbjs-1.0.0.tgz#52c215e0883a3c86af2a7a776ed51525ae8e0a5a" + integrity sha512-MUgcMEJaFhCaF1QtWGnmq9ZDRAzECTCRAF7O6UZIlAlkTs1SasiX9aP0Iw7wfD2mJ7wDTNfg2w7u5fSCwJk1OA== dependencies: - core-js "^1.0.0" + core-js "^2.4.1" + fbjs-css-vars "^1.0.0" isomorphic-fetch "^2.1.1" loose-envify "^1.0.0" object-assign "^4.1.0" @@ -2436,13 +2437,12 @@ fbjs@^0.8.9: setimmediate "^1.0.5" ua-parser-js "^0.7.18" -fbjs@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/fbjs/-/fbjs-1.0.0.tgz#52c215e0883a3c86af2a7a776ed51525ae8e0a5a" - integrity sha512-MUgcMEJaFhCaF1QtWGnmq9ZDRAzECTCRAF7O6UZIlAlkTs1SasiX9aP0Iw7wfD2mJ7wDTNfg2w7u5fSCwJk1OA== +fbjs@^0.8.9: + version "0.8.17" + resolved "https://registry.yarnpkg.com/fbjs/-/fbjs-0.8.17.tgz#c4d598ead6949112653d6588b01a5cdcd9f90fdd" + integrity sha1-xNWY6taUkRJlPWWIsBpc3Nn5D90= dependencies: - core-js "^2.4.1" - fbjs-css-vars "^1.0.0" + core-js "^1.0.0" isomorphic-fetch "^2.1.1" loose-envify "^1.0.0" object-assign "^4.1.0" @@ -5223,10 +5223,10 @@ react-devtools-core@^3.4.0: shell-quote "^1.6.1" ws "^3.3.1" -react-is@^16.6.1: - version "16.6.1" - resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.6.1.tgz#f77b1c3d901be300abe8d58645b7a59e794e5982" - integrity sha512-wOKsGtvTMYs7WAscmwwdM8sfRRvE17Ym30zFj3n37Qx5tHRfhenPKEPILHaHob6WoLFADmQm1ZNrE5xMCM6sCw== +react-is@^16.6.3: + version "16.6.3" + resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.6.3.tgz#d2d7462fcfcbe6ec0da56ad69047e47e56e7eac0" + integrity sha512-u7FDWtthB4rWibG/+mFbVd5FvdI20yde86qKGx4lVUTWmPlSWQ4QxbBIrrs+HnXGbxOUlUzTAP/VDmvCwaP2yA== react-native-dummy@0.1.0: version "0.1.0" @@ -5241,15 +5241,15 @@ react-proxy@^1.1.7: lodash "^4.6.1" react-deep-force-update "^1.0.0" -react-test-renderer@16.6.1: - version "16.6.1" - resolved "https://registry.yarnpkg.com/react-test-renderer/-/react-test-renderer-16.6.1.tgz#8ea357652be3cf81cbd6b2f686e74ebe67c17b78" - integrity sha512-sgZwJZYIgQptRi2qk5+gB8FBQGk4gLSs0gmKZPMfhd3dLkdxIUwVLHteLN3Bnj4LokIZd3U+V2NEJUqeV2PT2w== +react-test-renderer@16.6.3: + version "16.6.3" + resolved "https://registry.yarnpkg.com/react-test-renderer/-/react-test-renderer-16.6.3.tgz#5f3a1a7d5c3379d46f7052b848b4b72e47c89f38" + integrity sha512-B5bCer+qymrQz/wN03lT0LppbZUDRq6AMfzMKrovzkGzfO81a9T+PWQW6MzkWknbwODQH/qpJno/yFQLX5IWrQ== dependencies: object-assign "^4.1.1" prop-types "^15.6.2" - react-is "^16.6.1" - scheduler "^0.11.0" + react-is "^16.6.3" + scheduler "^0.11.2" react-transform-hmr@^1.0.4: version "1.0.4" @@ -5259,15 +5259,15 @@ react-transform-hmr@^1.0.4: global "^4.3.0" react-proxy "^1.1.7" -react@16.6.1: - version "16.6.1" - resolved "https://registry.yarnpkg.com/react/-/react-16.6.1.tgz#ee2aef4f0a09e494594882029821049772f915fe" - integrity sha512-OtawJThYlvRgm9BXK+xTL7BIlDx8vv21j+fbQDjRRUyok6y7NyjlweGorielTahLZHYIdKUoK2Dp9ByVWuMqxw== +react@16.6.3: + version "16.6.3" + resolved "https://registry.yarnpkg.com/react/-/react-16.6.3.tgz#25d77c91911d6bbdd23db41e70fb094cc1e0871c" + integrity sha512-zCvmH2vbEolgKxtqXL2wmGCUxUyNheYn/C+PD1YAjfxHC54+MhdruyhO7QieQrYsYeTxrn93PM2y0jRH1zEExw== dependencies: loose-envify "^1.1.0" object-assign "^4.1.1" prop-types "^15.6.2" - scheduler "^0.11.0" + scheduler "^0.11.2" read-pkg-up@^1.0.1: version "1.0.1" @@ -5650,10 +5650,10 @@ sax@~1.1.1: resolved "http://registry.npmjs.org/sax/-/sax-1.1.6.tgz#5d616be8a5e607d54e114afae55b7eaf2fcc3240" integrity sha1-XWFr6KXmB9VOEUr65Vt+ry/MMkA= -scheduler@^0.11.0: - version "0.11.0" - resolved "https://registry.yarnpkg.com/scheduler/-/scheduler-0.11.0.tgz#def1f1bfa6550cc57981a87106e65e8aea41a6b5" - integrity sha512-MAYbBfmiEHxF0W+c4CxMpEqMYK+rYF584VP/qMKSiHM6lTkBKKYOJaDiSILpJHla6hBOsVd6GucPL46o2Uq3sg== +scheduler@^0.11.2: + version "0.11.2" + resolved "https://registry.yarnpkg.com/scheduler/-/scheduler-0.11.2.tgz#a8db5399d06eba5abac51b705b7151d2319d33d3" + integrity sha512-+WCP3s3wOaW4S7C1tl3TEXp4l9lJn0ZK8G3W3WKRWmw77Z2cIFUW2MiNTMHn5sCjxN+t7N43HAOOgMjyAg5hlg== dependencies: loose-envify "^1.1.0" object-assign "^4.1.1"