From b7bb25fe4c1bfbedb5b8c75725721cf901dc54b0 Mon Sep 17 00:00:00 2001 From: Andrew Clark Date: Wed, 25 Jul 2018 16:03:19 -0700 Subject: [PATCH] React sync for revisions ca0941f...bc1ea9c Summary: @public This sync includes the following changes: - **[bc1ea9cd9](https://github.com/facebook/react/commit/bc1ea9cd9)**: Handle errors thrown in gDSFP of a module-style context provider (#13269) //// - **[0154a79fe](https://github.com/facebook/react/commit/0154a79fe)**: Remove 'warning' module from the JS scheduler (#13264) //// - **[dbd16c8a9](https://github.com/facebook/react/commit/dbd16c8a9)**: Add flow directive to findDOMNode shim (#13265) //// Release Notes: [GENERAL] [FEATURE] [React] - React sync for revisions ca0941f...bc1ea9c Reviewed By: bvaughn Differential Revision: D9005608 fbshipit-source-id: c293add468badc5323179fda9341912710d4e840 --- Libraries/Renderer/REVISION | 2 +- Libraries/Renderer/oss/ReactFabric-dev.js | 9 +- Libraries/Renderer/oss/ReactFabric-prod.js | 134 +++++++++--------- .../Renderer/oss/ReactFabric-profiling.js | 134 +++++++++--------- .../Renderer/oss/ReactNativeRenderer-dev.js | 9 +- .../Renderer/oss/ReactNativeRenderer-prod.js | 134 +++++++++--------- .../oss/ReactNativeRenderer-profiling.js | 134 +++++++++--------- 7 files changed, 283 insertions(+), 273 deletions(-) diff --git a/Libraries/Renderer/REVISION b/Libraries/Renderer/REVISION index fd03ac6eef8990..1741b7411482a1 100644 --- a/Libraries/Renderer/REVISION +++ b/Libraries/Renderer/REVISION @@ -1 +1 @@ -ca0941fce3a03592530f6111f77cbc9c0daf79af \ No newline at end of file +bc1ea9cd96c81467c574b134349eafc303835d0e \ No newline at end of file diff --git a/Libraries/Renderer/oss/ReactFabric-dev.js b/Libraries/Renderer/oss/ReactFabric-dev.js index bb66ba4e0ffe47..2d6425b4214a8f 100644 --- a/Libraries/Renderer/oss/ReactFabric-dev.js +++ b/Libraries/Renderer/oss/ReactFabric-dev.js @@ -10379,6 +10379,11 @@ function mountIndeterminateComponent( // Proceed under the assumption that this is a class instance workInProgress.tag = ClassComponent; + // Push context providers early to prevent context stack mismatches. + // During mounting we don't know the child context yet as the instance doesn't exist. + // We will invalidate the child context in finishClassComponent() right after rendering. + var hasContext = pushContextProvider(workInProgress); + workInProgress.memoizedState = value.state !== null && value.state !== undefined ? value.state : null; @@ -10391,10 +10396,6 @@ function mountIndeterminateComponent( ); } - // Push context providers early to prevent context stack mismatches. - // During mounting we don't know the child context yet as the instance doesn't exist. - // We will invalidate the child context in finishClassComponent() right after rendering. - var hasContext = pushContextProvider(workInProgress); adoptClassInstance(workInProgress, value); mountClassInstance(workInProgress, renderExpirationTime); return finishClassComponent( diff --git a/Libraries/Renderer/oss/ReactFabric-prod.js b/Libraries/Renderer/oss/ReactFabric-prod.js index 3b9bbfd035c1b0..ab3317fa88ebd0 100644 --- a/Libraries/Renderer/oss/ReactFabric-prod.js +++ b/Libraries/Renderer/oss/ReactFabric-prod.js @@ -3490,34 +3490,37 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { prepareToReadContext(workInProgress, renderExpirationTime); fn = fn(updateExpirationTime, unmaskedContext); workInProgress.effectTag |= 1; - "object" === typeof fn && - null !== fn && - "function" === typeof fn.render && - void 0 === fn.$$typeof - ? ((unmaskedContext = workInProgress.type), - (workInProgress.tag = 2), - (workInProgress.memoizedState = - null !== fn.state && void 0 !== fn.state ? fn.state : null), - (unmaskedContext = unmaskedContext.getDerivedStateFromProps), - "function" === typeof unmaskedContext && - applyDerivedStateFromProps( - workInProgress, - unmaskedContext, - updateExpirationTime - ), - (updateExpirationTime = pushContextProvider(workInProgress)), - (fn.updater = classComponentUpdater), - (workInProgress.stateNode = fn), - (fn._reactInternalFiber = workInProgress), - mountClassInstance(workInProgress, renderExpirationTime), - (current$$1 = finishClassComponent( - current$$1, + if ( + "object" === typeof fn && + null !== fn && + "function" === typeof fn.render && + void 0 === fn.$$typeof + ) { + var Component = workInProgress.type; + workInProgress.tag = 2; + unmaskedContext = pushContextProvider(workInProgress); + workInProgress.memoizedState = + null !== fn.state && void 0 !== fn.state ? fn.state : null; + Component = Component.getDerivedStateFromProps; + "function" === typeof Component && + applyDerivedStateFromProps( workInProgress, - !0, - updateExpirationTime, - renderExpirationTime - ))) - : ((workInProgress.tag = 1), + Component, + updateExpirationTime + ); + fn.updater = classComponentUpdater; + workInProgress.stateNode = fn; + fn._reactInternalFiber = workInProgress; + mountClassInstance(workInProgress, renderExpirationTime); + current$$1 = finishClassComponent( + current$$1, + workInProgress, + !0, + unmaskedContext, + renderExpirationTime + ); + } else + (workInProgress.tag = 1), reconcileChildren( current$$1, workInProgress, @@ -3525,7 +3528,7 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { renderExpirationTime ), (workInProgress.memoizedProps = updateExpirationTime), - (current$$1 = workInProgress.child)); + (current$$1 = workInProgress.child); return current$$1; case 1: return ( @@ -3548,10 +3551,9 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { var props = workInProgress.pendingProps, ctor = workInProgress.type; fn = getUnmaskedContext(workInProgress); - var needsContext = + unmaskedContext = (Component = 2 === workInProgress.tag && - null != workInProgress.type.contextTypes; - unmaskedContext = needsContext + null != workInProgress.type.contextTypes) ? getMaskedContext(workInProgress, fn) : emptyContextObject; props = new ctor(props, unmaskedContext); @@ -3560,17 +3562,17 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { props.updater = classComponentUpdater; workInProgress.stateNode = props; props._reactInternalFiber = workInProgress; - needsContext && - ((needsContext = workInProgress.stateNode), - (needsContext.__reactInternalMemoizedUnmaskedChildContext = fn), - (needsContext.__reactInternalMemoizedMaskedChildContext = unmaskedContext)); + Component && + ((Component = workInProgress.stateNode), + (Component.__reactInternalMemoizedUnmaskedChildContext = fn), + (Component.__reactInternalMemoizedMaskedChildContext = unmaskedContext)); mountClassInstance(workInProgress, renderExpirationTime); fn = !0; } else { var ctor$jscomp$0 = workInProgress.type; unmaskedContext = workInProgress.stateNode; props = workInProgress.memoizedProps; - needsContext = workInProgress.pendingProps; + Component = workInProgress.pendingProps; unmaskedContext.props = props; var oldContext = unmaskedContext.context; ctor = getUnmaskedContext(workInProgress); @@ -3583,11 +3585,11 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { typeof unmaskedContext.UNSAFE_componentWillReceiveProps && "function" !== typeof unmaskedContext.componentWillReceiveProps) || - ((props !== needsContext || oldContext !== ctor) && + ((props !== Component || oldContext !== ctor) && callComponentWillReceiveProps( workInProgress, unmaskedContext, - needsContext, + Component, ctor )); hasForceUpdate = !1; @@ -3598,12 +3600,12 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { (processUpdateQueue( workInProgress, updateQueue, - needsContext, + Component, unmaskedContext, renderExpirationTime ), (oldContext = workInProgress.memoizedState)); - props !== needsContext || + props !== Component || oldState !== oldContext || didPerformWorkStackCursor.current || fn || @@ -3612,7 +3614,7 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { (applyDerivedStateFromProps( workInProgress, getDerivedStateFromProps, - needsContext + Component ), (oldContext = workInProgress.memoizedState)), (fn = @@ -3621,7 +3623,7 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { checkShouldComponentUpdate( workInProgress, props, - needsContext, + Component, oldState, oldContext, ctor @@ -3640,9 +3642,9 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { (workInProgress.effectTag |= 4)) : ("function" === typeof unmaskedContext.componentDidMount && (workInProgress.effectTag |= 4), - (workInProgress.memoizedProps = needsContext), + (workInProgress.memoizedProps = Component), (workInProgress.memoizedState = oldContext)), - (unmaskedContext.props = needsContext), + (unmaskedContext.props = Component), (unmaskedContext.state = oldContext), (unmaskedContext.context = ctor)) : ("function" === typeof unmaskedContext.componentDidMount && @@ -3652,9 +3654,9 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { else (ctor$jscomp$0 = workInProgress.type), (unmaskedContext = workInProgress.stateNode), - (needsContext = workInProgress.memoizedProps), + (Component = workInProgress.memoizedProps), (props = workInProgress.pendingProps), - (unmaskedContext.props = needsContext), + (unmaskedContext.props = Component), (oldContext = unmaskedContext.context), (ctor = getUnmaskedContext(workInProgress)), (ctor = getMaskedContext(workInProgress, ctor)), @@ -3666,7 +3668,7 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { typeof unmaskedContext.UNSAFE_componentWillReceiveProps && "function" !== typeof unmaskedContext.componentWillReceiveProps) || - ((needsContext !== props || oldContext !== ctor) && + ((Component !== props || oldContext !== ctor) && callComponentWillReceiveProps( workInProgress, unmaskedContext, @@ -3686,7 +3688,7 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { renderExpirationTime ), (oldState = workInProgress.memoizedState)), - needsContext !== props || + Component !== props || oldContext !== oldState || didPerformWorkStackCursor.current || fn || @@ -3703,7 +3705,7 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { fn || checkShouldComponentUpdate( workInProgress, - needsContext, + Component, props, oldContext, oldState, @@ -3734,12 +3736,12 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { typeof unmaskedContext.getSnapshotBeforeUpdate && (workInProgress.effectTag |= 256)) : ("function" !== typeof unmaskedContext.componentDidUpdate || - (needsContext === current$$1.memoizedProps && + (Component === current$$1.memoizedProps && oldContext === current$$1.memoizedState) || (workInProgress.effectTag |= 4), "function" !== typeof unmaskedContext.getSnapshotBeforeUpdate || - (needsContext === current$$1.memoizedProps && + (Component === current$$1.memoizedProps && oldContext === current$$1.memoizedState) || (workInProgress.effectTag |= 256), (workInProgress.memoizedProps = props), @@ -3748,11 +3750,11 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { (unmaskedContext.state = oldState), (unmaskedContext.context = ctor)) : ("function" !== typeof unmaskedContext.componentDidUpdate || - (needsContext === current$$1.memoizedProps && + (Component === current$$1.memoizedProps && oldContext === current$$1.memoizedState) || (workInProgress.effectTag |= 4), "function" !== typeof unmaskedContext.getSnapshotBeforeUpdate || - (needsContext === current$$1.memoizedProps && + (Component === current$$1.memoizedProps && oldContext === current$$1.memoizedState) || (workInProgress.effectTag |= 256), (fn = !1)); @@ -3904,9 +3906,9 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { updateExpirationTime = workInProgress.type._context; fn = workInProgress.pendingProps; unmaskedContext = workInProgress.memoizedProps; - needsContext = fn.value; + Component = fn.value; workInProgress.memoizedProps = fn; - if (null === unmaskedContext) needsContext = 1073741823; + if (null === unmaskedContext) Component = 1073741823; else if (unmaskedContext.value === fn.value) { if ( unmaskedContext.children === fn.children && @@ -3921,12 +3923,12 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { ); break a; } - needsContext = 0; + Component = 0; } else if ( ((props = unmaskedContext.value), - (props === needsContext && - (0 !== props || 1 / props === 1 / needsContext)) || - (props !== props && needsContext !== needsContext)) + (props === Component && + (0 !== props || 1 / props === 1 / Component)) || + (props !== props && Component !== Component)) ) { if ( unmaskedContext.children === fn.children && @@ -3941,14 +3943,14 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { ); break a; } - needsContext = 0; + Component = 0; } else if ( - ((needsContext = + ((Component = "function" === typeof updateExpirationTime._calculateChangedBits - ? updateExpirationTime._calculateChangedBits(props, needsContext) + ? updateExpirationTime._calculateChangedBits(props, Component) : 1073741823), - (needsContext |= 0), - 0 === needsContext) + (Component |= 0), + 0 === Component) ) { if ( unmaskedContext.children === fn.children && @@ -3967,10 +3969,10 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { propagateContextChange( workInProgress, updateExpirationTime, - needsContext, + Component, renderExpirationTime ); - workInProgress.stateNode = needsContext; + workInProgress.stateNode = Component; pushProvider(workInProgress); reconcileChildren( current$$1, diff --git a/Libraries/Renderer/oss/ReactFabric-profiling.js b/Libraries/Renderer/oss/ReactFabric-profiling.js index 33e0f44b7a69c6..91cc588cc36027 100644 --- a/Libraries/Renderer/oss/ReactFabric-profiling.js +++ b/Libraries/Renderer/oss/ReactFabric-profiling.js @@ -3531,34 +3531,37 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { prepareToReadContext(workInProgress, renderExpirationTime); fn = fn(updateExpirationTime, unmaskedContext); workInProgress.effectTag |= 1; - "object" === typeof fn && - null !== fn && - "function" === typeof fn.render && - void 0 === fn.$$typeof - ? ((unmaskedContext = workInProgress.type), - (workInProgress.tag = 2), - (workInProgress.memoizedState = - null !== fn.state && void 0 !== fn.state ? fn.state : null), - (unmaskedContext = unmaskedContext.getDerivedStateFromProps), - "function" === typeof unmaskedContext && - applyDerivedStateFromProps( - workInProgress, - unmaskedContext, - updateExpirationTime - ), - (updateExpirationTime = pushContextProvider(workInProgress)), - (fn.updater = classComponentUpdater), - (workInProgress.stateNode = fn), - (fn._reactInternalFiber = workInProgress), - mountClassInstance(workInProgress, renderExpirationTime), - (current$$1 = finishClassComponent( - current$$1, + if ( + "object" === typeof fn && + null !== fn && + "function" === typeof fn.render && + void 0 === fn.$$typeof + ) { + var Component = workInProgress.type; + workInProgress.tag = 2; + unmaskedContext = pushContextProvider(workInProgress); + workInProgress.memoizedState = + null !== fn.state && void 0 !== fn.state ? fn.state : null; + Component = Component.getDerivedStateFromProps; + "function" === typeof Component && + applyDerivedStateFromProps( workInProgress, - !0, - updateExpirationTime, - renderExpirationTime - ))) - : ((workInProgress.tag = 1), + Component, + updateExpirationTime + ); + fn.updater = classComponentUpdater; + workInProgress.stateNode = fn; + fn._reactInternalFiber = workInProgress; + mountClassInstance(workInProgress, renderExpirationTime); + current$$1 = finishClassComponent( + current$$1, + workInProgress, + !0, + unmaskedContext, + renderExpirationTime + ); + } else + (workInProgress.tag = 1), reconcileChildren( current$$1, workInProgress, @@ -3566,7 +3569,7 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { renderExpirationTime ), (workInProgress.memoizedProps = updateExpirationTime), - (current$$1 = workInProgress.child)); + (current$$1 = workInProgress.child); return current$$1; case 1: return ( @@ -3589,10 +3592,9 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { var props = workInProgress.pendingProps, ctor = workInProgress.type; fn = getUnmaskedContext(workInProgress); - var needsContext = + unmaskedContext = (Component = 2 === workInProgress.tag && - null != workInProgress.type.contextTypes; - unmaskedContext = needsContext + null != workInProgress.type.contextTypes) ? getMaskedContext(workInProgress, fn) : emptyContextObject; props = new ctor(props, unmaskedContext); @@ -3601,17 +3603,17 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { props.updater = classComponentUpdater; workInProgress.stateNode = props; props._reactInternalFiber = workInProgress; - needsContext && - ((needsContext = workInProgress.stateNode), - (needsContext.__reactInternalMemoizedUnmaskedChildContext = fn), - (needsContext.__reactInternalMemoizedMaskedChildContext = unmaskedContext)); + Component && + ((Component = workInProgress.stateNode), + (Component.__reactInternalMemoizedUnmaskedChildContext = fn), + (Component.__reactInternalMemoizedMaskedChildContext = unmaskedContext)); mountClassInstance(workInProgress, renderExpirationTime); fn = !0; } else { var ctor$jscomp$0 = workInProgress.type; unmaskedContext = workInProgress.stateNode; props = workInProgress.memoizedProps; - needsContext = workInProgress.pendingProps; + Component = workInProgress.pendingProps; unmaskedContext.props = props; var oldContext = unmaskedContext.context; ctor = getUnmaskedContext(workInProgress); @@ -3624,11 +3626,11 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { typeof unmaskedContext.UNSAFE_componentWillReceiveProps && "function" !== typeof unmaskedContext.componentWillReceiveProps) || - ((props !== needsContext || oldContext !== ctor) && + ((props !== Component || oldContext !== ctor) && callComponentWillReceiveProps( workInProgress, unmaskedContext, - needsContext, + Component, ctor )); hasForceUpdate = !1; @@ -3639,12 +3641,12 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { (processUpdateQueue( workInProgress, updateQueue, - needsContext, + Component, unmaskedContext, renderExpirationTime ), (oldContext = workInProgress.memoizedState)); - props !== needsContext || + props !== Component || oldState !== oldContext || didPerformWorkStackCursor.current || fn || @@ -3653,7 +3655,7 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { (applyDerivedStateFromProps( workInProgress, getDerivedStateFromProps, - needsContext + Component ), (oldContext = workInProgress.memoizedState)), (fn = @@ -3662,7 +3664,7 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { checkShouldComponentUpdate( workInProgress, props, - needsContext, + Component, oldState, oldContext, ctor @@ -3681,9 +3683,9 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { (workInProgress.effectTag |= 4)) : ("function" === typeof unmaskedContext.componentDidMount && (workInProgress.effectTag |= 4), - (workInProgress.memoizedProps = needsContext), + (workInProgress.memoizedProps = Component), (workInProgress.memoizedState = oldContext)), - (unmaskedContext.props = needsContext), + (unmaskedContext.props = Component), (unmaskedContext.state = oldContext), (unmaskedContext.context = ctor)) : ("function" === typeof unmaskedContext.componentDidMount && @@ -3693,9 +3695,9 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { else (ctor$jscomp$0 = workInProgress.type), (unmaskedContext = workInProgress.stateNode), - (needsContext = workInProgress.memoizedProps), + (Component = workInProgress.memoizedProps), (props = workInProgress.pendingProps), - (unmaskedContext.props = needsContext), + (unmaskedContext.props = Component), (oldContext = unmaskedContext.context), (ctor = getUnmaskedContext(workInProgress)), (ctor = getMaskedContext(workInProgress, ctor)), @@ -3707,7 +3709,7 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { typeof unmaskedContext.UNSAFE_componentWillReceiveProps && "function" !== typeof unmaskedContext.componentWillReceiveProps) || - ((needsContext !== props || oldContext !== ctor) && + ((Component !== props || oldContext !== ctor) && callComponentWillReceiveProps( workInProgress, unmaskedContext, @@ -3727,7 +3729,7 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { renderExpirationTime ), (oldState = workInProgress.memoizedState)), - needsContext !== props || + Component !== props || oldContext !== oldState || didPerformWorkStackCursor.current || fn || @@ -3744,7 +3746,7 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { fn || checkShouldComponentUpdate( workInProgress, - needsContext, + Component, props, oldContext, oldState, @@ -3775,12 +3777,12 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { typeof unmaskedContext.getSnapshotBeforeUpdate && (workInProgress.effectTag |= 256)) : ("function" !== typeof unmaskedContext.componentDidUpdate || - (needsContext === current$$1.memoizedProps && + (Component === current$$1.memoizedProps && oldContext === current$$1.memoizedState) || (workInProgress.effectTag |= 4), "function" !== typeof unmaskedContext.getSnapshotBeforeUpdate || - (needsContext === current$$1.memoizedProps && + (Component === current$$1.memoizedProps && oldContext === current$$1.memoizedState) || (workInProgress.effectTag |= 256), (workInProgress.memoizedProps = props), @@ -3789,11 +3791,11 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { (unmaskedContext.state = oldState), (unmaskedContext.context = ctor)) : ("function" !== typeof unmaskedContext.componentDidUpdate || - (needsContext === current$$1.memoizedProps && + (Component === current$$1.memoizedProps && oldContext === current$$1.memoizedState) || (workInProgress.effectTag |= 4), "function" !== typeof unmaskedContext.getSnapshotBeforeUpdate || - (needsContext === current$$1.memoizedProps && + (Component === current$$1.memoizedProps && oldContext === current$$1.memoizedState) || (workInProgress.effectTag |= 256), (fn = !1)); @@ -3946,9 +3948,9 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { updateExpirationTime = workInProgress.type._context; fn = workInProgress.pendingProps; unmaskedContext = workInProgress.memoizedProps; - needsContext = fn.value; + Component = fn.value; workInProgress.memoizedProps = fn; - if (null === unmaskedContext) needsContext = 1073741823; + if (null === unmaskedContext) Component = 1073741823; else if (unmaskedContext.value === fn.value) { if ( unmaskedContext.children === fn.children && @@ -3963,12 +3965,12 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { ); break a; } - needsContext = 0; + Component = 0; } else if ( ((props = unmaskedContext.value), - (props === needsContext && - (0 !== props || 1 / props === 1 / needsContext)) || - (props !== props && needsContext !== needsContext)) + (props === Component && + (0 !== props || 1 / props === 1 / Component)) || + (props !== props && Component !== Component)) ) { if ( unmaskedContext.children === fn.children && @@ -3983,14 +3985,14 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { ); break a; } - needsContext = 0; + Component = 0; } else if ( - ((needsContext = + ((Component = "function" === typeof updateExpirationTime._calculateChangedBits - ? updateExpirationTime._calculateChangedBits(props, needsContext) + ? updateExpirationTime._calculateChangedBits(props, Component) : 1073741823), - (needsContext |= 0), - 0 === needsContext) + (Component |= 0), + 0 === Component) ) { if ( unmaskedContext.children === fn.children && @@ -4009,10 +4011,10 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { propagateContextChange( workInProgress, updateExpirationTime, - needsContext, + Component, renderExpirationTime ); - workInProgress.stateNode = needsContext; + workInProgress.stateNode = Component; pushProvider(workInProgress); reconcileChildren( current$$1, diff --git a/Libraries/Renderer/oss/ReactNativeRenderer-dev.js b/Libraries/Renderer/oss/ReactNativeRenderer-dev.js index 05f219810769c2..9b68fa5a45759f 100644 --- a/Libraries/Renderer/oss/ReactNativeRenderer-dev.js +++ b/Libraries/Renderer/oss/ReactNativeRenderer-dev.js @@ -10672,6 +10672,11 @@ function mountIndeterminateComponent( // Proceed under the assumption that this is a class instance workInProgress.tag = ClassComponent; + // Push context providers early to prevent context stack mismatches. + // During mounting we don't know the child context yet as the instance doesn't exist. + // We will invalidate the child context in finishClassComponent() right after rendering. + var hasContext = pushContextProvider(workInProgress); + workInProgress.memoizedState = value.state !== null && value.state !== undefined ? value.state : null; @@ -10684,10 +10689,6 @@ function mountIndeterminateComponent( ); } - // Push context providers early to prevent context stack mismatches. - // During mounting we don't know the child context yet as the instance doesn't exist. - // We will invalidate the child context in finishClassComponent() right after rendering. - var hasContext = pushContextProvider(workInProgress); adoptClassInstance(workInProgress, value); mountClassInstance(workInProgress, renderExpirationTime); return finishClassComponent( diff --git a/Libraries/Renderer/oss/ReactNativeRenderer-prod.js b/Libraries/Renderer/oss/ReactNativeRenderer-prod.js index 80d35730f77d59..4b5462dfad88e4 100644 --- a/Libraries/Renderer/oss/ReactNativeRenderer-prod.js +++ b/Libraries/Renderer/oss/ReactNativeRenderer-prod.js @@ -3545,34 +3545,37 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { prepareToReadContext(workInProgress, renderExpirationTime); fn = fn(updateExpirationTime, unmaskedContext); workInProgress.effectTag |= 1; - "object" === typeof fn && - null !== fn && - "function" === typeof fn.render && - void 0 === fn.$$typeof - ? ((unmaskedContext = workInProgress.type), - (workInProgress.tag = 2), - (workInProgress.memoizedState = - null !== fn.state && void 0 !== fn.state ? fn.state : null), - (unmaskedContext = unmaskedContext.getDerivedStateFromProps), - "function" === typeof unmaskedContext && - applyDerivedStateFromProps( - workInProgress, - unmaskedContext, - updateExpirationTime - ), - (updateExpirationTime = pushContextProvider(workInProgress)), - (fn.updater = classComponentUpdater), - (workInProgress.stateNode = fn), - (fn._reactInternalFiber = workInProgress), - mountClassInstance(workInProgress, renderExpirationTime), - (current$$1 = finishClassComponent( - current$$1, + if ( + "object" === typeof fn && + null !== fn && + "function" === typeof fn.render && + void 0 === fn.$$typeof + ) { + var Component = workInProgress.type; + workInProgress.tag = 2; + unmaskedContext = pushContextProvider(workInProgress); + workInProgress.memoizedState = + null !== fn.state && void 0 !== fn.state ? fn.state : null; + Component = Component.getDerivedStateFromProps; + "function" === typeof Component && + applyDerivedStateFromProps( workInProgress, - !0, - updateExpirationTime, - renderExpirationTime - ))) - : ((workInProgress.tag = 1), + Component, + updateExpirationTime + ); + fn.updater = classComponentUpdater; + workInProgress.stateNode = fn; + fn._reactInternalFiber = workInProgress; + mountClassInstance(workInProgress, renderExpirationTime); + current$$1 = finishClassComponent( + current$$1, + workInProgress, + !0, + unmaskedContext, + renderExpirationTime + ); + } else + (workInProgress.tag = 1), reconcileChildren( current$$1, workInProgress, @@ -3580,7 +3583,7 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { renderExpirationTime ), (workInProgress.memoizedProps = updateExpirationTime), - (current$$1 = workInProgress.child)); + (current$$1 = workInProgress.child); return current$$1; case 1: return ( @@ -3603,10 +3606,9 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { var props = workInProgress.pendingProps, ctor = workInProgress.type; fn = getUnmaskedContext(workInProgress); - var needsContext = + unmaskedContext = (Component = 2 === workInProgress.tag && - null != workInProgress.type.contextTypes; - unmaskedContext = needsContext + null != workInProgress.type.contextTypes) ? getMaskedContext(workInProgress, fn) : emptyContextObject; props = new ctor(props, unmaskedContext); @@ -3615,17 +3617,17 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { props.updater = classComponentUpdater; workInProgress.stateNode = props; props._reactInternalFiber = workInProgress; - needsContext && - ((needsContext = workInProgress.stateNode), - (needsContext.__reactInternalMemoizedUnmaskedChildContext = fn), - (needsContext.__reactInternalMemoizedMaskedChildContext = unmaskedContext)); + Component && + ((Component = workInProgress.stateNode), + (Component.__reactInternalMemoizedUnmaskedChildContext = fn), + (Component.__reactInternalMemoizedMaskedChildContext = unmaskedContext)); mountClassInstance(workInProgress, renderExpirationTime); fn = !0; } else { var ctor$jscomp$0 = workInProgress.type; unmaskedContext = workInProgress.stateNode; props = workInProgress.memoizedProps; - needsContext = workInProgress.pendingProps; + Component = workInProgress.pendingProps; unmaskedContext.props = props; var oldContext = unmaskedContext.context; ctor = getUnmaskedContext(workInProgress); @@ -3638,11 +3640,11 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { typeof unmaskedContext.UNSAFE_componentWillReceiveProps && "function" !== typeof unmaskedContext.componentWillReceiveProps) || - ((props !== needsContext || oldContext !== ctor) && + ((props !== Component || oldContext !== ctor) && callComponentWillReceiveProps( workInProgress, unmaskedContext, - needsContext, + Component, ctor )); hasForceUpdate = !1; @@ -3653,12 +3655,12 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { (processUpdateQueue( workInProgress, updateQueue, - needsContext, + Component, unmaskedContext, renderExpirationTime ), (oldContext = workInProgress.memoizedState)); - props !== needsContext || + props !== Component || oldState !== oldContext || didPerformWorkStackCursor.current || fn || @@ -3667,7 +3669,7 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { (applyDerivedStateFromProps( workInProgress, getDerivedStateFromProps, - needsContext + Component ), (oldContext = workInProgress.memoizedState)), (fn = @@ -3676,7 +3678,7 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { checkShouldComponentUpdate( workInProgress, props, - needsContext, + Component, oldState, oldContext, ctor @@ -3695,9 +3697,9 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { (workInProgress.effectTag |= 4)) : ("function" === typeof unmaskedContext.componentDidMount && (workInProgress.effectTag |= 4), - (workInProgress.memoizedProps = needsContext), + (workInProgress.memoizedProps = Component), (workInProgress.memoizedState = oldContext)), - (unmaskedContext.props = needsContext), + (unmaskedContext.props = Component), (unmaskedContext.state = oldContext), (unmaskedContext.context = ctor)) : ("function" === typeof unmaskedContext.componentDidMount && @@ -3707,9 +3709,9 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { else (ctor$jscomp$0 = workInProgress.type), (unmaskedContext = workInProgress.stateNode), - (needsContext = workInProgress.memoizedProps), + (Component = workInProgress.memoizedProps), (props = workInProgress.pendingProps), - (unmaskedContext.props = needsContext), + (unmaskedContext.props = Component), (oldContext = unmaskedContext.context), (ctor = getUnmaskedContext(workInProgress)), (ctor = getMaskedContext(workInProgress, ctor)), @@ -3721,7 +3723,7 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { typeof unmaskedContext.UNSAFE_componentWillReceiveProps && "function" !== typeof unmaskedContext.componentWillReceiveProps) || - ((needsContext !== props || oldContext !== ctor) && + ((Component !== props || oldContext !== ctor) && callComponentWillReceiveProps( workInProgress, unmaskedContext, @@ -3741,7 +3743,7 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { renderExpirationTime ), (oldState = workInProgress.memoizedState)), - needsContext !== props || + Component !== props || oldContext !== oldState || didPerformWorkStackCursor.current || fn || @@ -3758,7 +3760,7 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { fn || checkShouldComponentUpdate( workInProgress, - needsContext, + Component, props, oldContext, oldState, @@ -3789,12 +3791,12 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { typeof unmaskedContext.getSnapshotBeforeUpdate && (workInProgress.effectTag |= 256)) : ("function" !== typeof unmaskedContext.componentDidUpdate || - (needsContext === current$$1.memoizedProps && + (Component === current$$1.memoizedProps && oldContext === current$$1.memoizedState) || (workInProgress.effectTag |= 4), "function" !== typeof unmaskedContext.getSnapshotBeforeUpdate || - (needsContext === current$$1.memoizedProps && + (Component === current$$1.memoizedProps && oldContext === current$$1.memoizedState) || (workInProgress.effectTag |= 256), (workInProgress.memoizedProps = props), @@ -3803,11 +3805,11 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { (unmaskedContext.state = oldState), (unmaskedContext.context = ctor)) : ("function" !== typeof unmaskedContext.componentDidUpdate || - (needsContext === current$$1.memoizedProps && + (Component === current$$1.memoizedProps && oldContext === current$$1.memoizedState) || (workInProgress.effectTag |= 4), "function" !== typeof unmaskedContext.getSnapshotBeforeUpdate || - (needsContext === current$$1.memoizedProps && + (Component === current$$1.memoizedProps && oldContext === current$$1.memoizedState) || (workInProgress.effectTag |= 256), (fn = !1)); @@ -3959,9 +3961,9 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { updateExpirationTime = workInProgress.type._context; fn = workInProgress.pendingProps; unmaskedContext = workInProgress.memoizedProps; - needsContext = fn.value; + Component = fn.value; workInProgress.memoizedProps = fn; - if (null === unmaskedContext) needsContext = 1073741823; + if (null === unmaskedContext) Component = 1073741823; else if (unmaskedContext.value === fn.value) { if ( unmaskedContext.children === fn.children && @@ -3976,12 +3978,12 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { ); break a; } - needsContext = 0; + Component = 0; } else if ( ((props = unmaskedContext.value), - (props === needsContext && - (0 !== props || 1 / props === 1 / needsContext)) || - (props !== props && needsContext !== needsContext)) + (props === Component && + (0 !== props || 1 / props === 1 / Component)) || + (props !== props && Component !== Component)) ) { if ( unmaskedContext.children === fn.children && @@ -3996,14 +3998,14 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { ); break a; } - needsContext = 0; + Component = 0; } else if ( - ((needsContext = + ((Component = "function" === typeof updateExpirationTime._calculateChangedBits - ? updateExpirationTime._calculateChangedBits(props, needsContext) + ? updateExpirationTime._calculateChangedBits(props, Component) : 1073741823), - (needsContext |= 0), - 0 === needsContext) + (Component |= 0), + 0 === Component) ) { if ( unmaskedContext.children === fn.children && @@ -4022,10 +4024,10 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { propagateContextChange( workInProgress, updateExpirationTime, - needsContext, + Component, renderExpirationTime ); - workInProgress.stateNode = needsContext; + workInProgress.stateNode = Component; pushProvider(workInProgress); reconcileChildren( current$$1, diff --git a/Libraries/Renderer/oss/ReactNativeRenderer-profiling.js b/Libraries/Renderer/oss/ReactNativeRenderer-profiling.js index 8bc0925c179655..6ef889e1d9a115 100644 --- a/Libraries/Renderer/oss/ReactNativeRenderer-profiling.js +++ b/Libraries/Renderer/oss/ReactNativeRenderer-profiling.js @@ -3587,34 +3587,37 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { prepareToReadContext(workInProgress, renderExpirationTime); fn = fn(updateExpirationTime, unmaskedContext); workInProgress.effectTag |= 1; - "object" === typeof fn && - null !== fn && - "function" === typeof fn.render && - void 0 === fn.$$typeof - ? ((unmaskedContext = workInProgress.type), - (workInProgress.tag = 2), - (workInProgress.memoizedState = - null !== fn.state && void 0 !== fn.state ? fn.state : null), - (unmaskedContext = unmaskedContext.getDerivedStateFromProps), - "function" === typeof unmaskedContext && - applyDerivedStateFromProps( - workInProgress, - unmaskedContext, - updateExpirationTime - ), - (updateExpirationTime = pushContextProvider(workInProgress)), - (fn.updater = classComponentUpdater), - (workInProgress.stateNode = fn), - (fn._reactInternalFiber = workInProgress), - mountClassInstance(workInProgress, renderExpirationTime), - (current$$1 = finishClassComponent( - current$$1, + if ( + "object" === typeof fn && + null !== fn && + "function" === typeof fn.render && + void 0 === fn.$$typeof + ) { + var Component = workInProgress.type; + workInProgress.tag = 2; + unmaskedContext = pushContextProvider(workInProgress); + workInProgress.memoizedState = + null !== fn.state && void 0 !== fn.state ? fn.state : null; + Component = Component.getDerivedStateFromProps; + "function" === typeof Component && + applyDerivedStateFromProps( workInProgress, - !0, - updateExpirationTime, - renderExpirationTime - ))) - : ((workInProgress.tag = 1), + Component, + updateExpirationTime + ); + fn.updater = classComponentUpdater; + workInProgress.stateNode = fn; + fn._reactInternalFiber = workInProgress; + mountClassInstance(workInProgress, renderExpirationTime); + current$$1 = finishClassComponent( + current$$1, + workInProgress, + !0, + unmaskedContext, + renderExpirationTime + ); + } else + (workInProgress.tag = 1), reconcileChildren( current$$1, workInProgress, @@ -3622,7 +3625,7 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { renderExpirationTime ), (workInProgress.memoizedProps = updateExpirationTime), - (current$$1 = workInProgress.child)); + (current$$1 = workInProgress.child); return current$$1; case 1: return ( @@ -3645,10 +3648,9 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { var props = workInProgress.pendingProps, ctor = workInProgress.type; fn = getUnmaskedContext(workInProgress); - var needsContext = + unmaskedContext = (Component = 2 === workInProgress.tag && - null != workInProgress.type.contextTypes; - unmaskedContext = needsContext + null != workInProgress.type.contextTypes) ? getMaskedContext(workInProgress, fn) : emptyContextObject; props = new ctor(props, unmaskedContext); @@ -3657,17 +3659,17 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { props.updater = classComponentUpdater; workInProgress.stateNode = props; props._reactInternalFiber = workInProgress; - needsContext && - ((needsContext = workInProgress.stateNode), - (needsContext.__reactInternalMemoizedUnmaskedChildContext = fn), - (needsContext.__reactInternalMemoizedMaskedChildContext = unmaskedContext)); + Component && + ((Component = workInProgress.stateNode), + (Component.__reactInternalMemoizedUnmaskedChildContext = fn), + (Component.__reactInternalMemoizedMaskedChildContext = unmaskedContext)); mountClassInstance(workInProgress, renderExpirationTime); fn = !0; } else { var ctor$jscomp$0 = workInProgress.type; unmaskedContext = workInProgress.stateNode; props = workInProgress.memoizedProps; - needsContext = workInProgress.pendingProps; + Component = workInProgress.pendingProps; unmaskedContext.props = props; var oldContext = unmaskedContext.context; ctor = getUnmaskedContext(workInProgress); @@ -3680,11 +3682,11 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { typeof unmaskedContext.UNSAFE_componentWillReceiveProps && "function" !== typeof unmaskedContext.componentWillReceiveProps) || - ((props !== needsContext || oldContext !== ctor) && + ((props !== Component || oldContext !== ctor) && callComponentWillReceiveProps( workInProgress, unmaskedContext, - needsContext, + Component, ctor )); hasForceUpdate = !1; @@ -3695,12 +3697,12 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { (processUpdateQueue( workInProgress, updateQueue, - needsContext, + Component, unmaskedContext, renderExpirationTime ), (oldContext = workInProgress.memoizedState)); - props !== needsContext || + props !== Component || oldState !== oldContext || didPerformWorkStackCursor.current || fn || @@ -3709,7 +3711,7 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { (applyDerivedStateFromProps( workInProgress, getDerivedStateFromProps, - needsContext + Component ), (oldContext = workInProgress.memoizedState)), (fn = @@ -3718,7 +3720,7 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { checkShouldComponentUpdate( workInProgress, props, - needsContext, + Component, oldState, oldContext, ctor @@ -3737,9 +3739,9 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { (workInProgress.effectTag |= 4)) : ("function" === typeof unmaskedContext.componentDidMount && (workInProgress.effectTag |= 4), - (workInProgress.memoizedProps = needsContext), + (workInProgress.memoizedProps = Component), (workInProgress.memoizedState = oldContext)), - (unmaskedContext.props = needsContext), + (unmaskedContext.props = Component), (unmaskedContext.state = oldContext), (unmaskedContext.context = ctor)) : ("function" === typeof unmaskedContext.componentDidMount && @@ -3749,9 +3751,9 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { else (ctor$jscomp$0 = workInProgress.type), (unmaskedContext = workInProgress.stateNode), - (needsContext = workInProgress.memoizedProps), + (Component = workInProgress.memoizedProps), (props = workInProgress.pendingProps), - (unmaskedContext.props = needsContext), + (unmaskedContext.props = Component), (oldContext = unmaskedContext.context), (ctor = getUnmaskedContext(workInProgress)), (ctor = getMaskedContext(workInProgress, ctor)), @@ -3763,7 +3765,7 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { typeof unmaskedContext.UNSAFE_componentWillReceiveProps && "function" !== typeof unmaskedContext.componentWillReceiveProps) || - ((needsContext !== props || oldContext !== ctor) && + ((Component !== props || oldContext !== ctor) && callComponentWillReceiveProps( workInProgress, unmaskedContext, @@ -3783,7 +3785,7 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { renderExpirationTime ), (oldState = workInProgress.memoizedState)), - needsContext !== props || + Component !== props || oldContext !== oldState || didPerformWorkStackCursor.current || fn || @@ -3800,7 +3802,7 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { fn || checkShouldComponentUpdate( workInProgress, - needsContext, + Component, props, oldContext, oldState, @@ -3831,12 +3833,12 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { typeof unmaskedContext.getSnapshotBeforeUpdate && (workInProgress.effectTag |= 256)) : ("function" !== typeof unmaskedContext.componentDidUpdate || - (needsContext === current$$1.memoizedProps && + (Component === current$$1.memoizedProps && oldContext === current$$1.memoizedState) || (workInProgress.effectTag |= 4), "function" !== typeof unmaskedContext.getSnapshotBeforeUpdate || - (needsContext === current$$1.memoizedProps && + (Component === current$$1.memoizedProps && oldContext === current$$1.memoizedState) || (workInProgress.effectTag |= 256), (workInProgress.memoizedProps = props), @@ -3845,11 +3847,11 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { (unmaskedContext.state = oldState), (unmaskedContext.context = ctor)) : ("function" !== typeof unmaskedContext.componentDidUpdate || - (needsContext === current$$1.memoizedProps && + (Component === current$$1.memoizedProps && oldContext === current$$1.memoizedState) || (workInProgress.effectTag |= 4), "function" !== typeof unmaskedContext.getSnapshotBeforeUpdate || - (needsContext === current$$1.memoizedProps && + (Component === current$$1.memoizedProps && oldContext === current$$1.memoizedState) || (workInProgress.effectTag |= 256), (fn = !1)); @@ -4002,9 +4004,9 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { updateExpirationTime = workInProgress.type._context; fn = workInProgress.pendingProps; unmaskedContext = workInProgress.memoizedProps; - needsContext = fn.value; + Component = fn.value; workInProgress.memoizedProps = fn; - if (null === unmaskedContext) needsContext = 1073741823; + if (null === unmaskedContext) Component = 1073741823; else if (unmaskedContext.value === fn.value) { if ( unmaskedContext.children === fn.children && @@ -4019,12 +4021,12 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { ); break a; } - needsContext = 0; + Component = 0; } else if ( ((props = unmaskedContext.value), - (props === needsContext && - (0 !== props || 1 / props === 1 / needsContext)) || - (props !== props && needsContext !== needsContext)) + (props === Component && + (0 !== props || 1 / props === 1 / Component)) || + (props !== props && Component !== Component)) ) { if ( unmaskedContext.children === fn.children && @@ -4039,14 +4041,14 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { ); break a; } - needsContext = 0; + Component = 0; } else if ( - ((needsContext = + ((Component = "function" === typeof updateExpirationTime._calculateChangedBits - ? updateExpirationTime._calculateChangedBits(props, needsContext) + ? updateExpirationTime._calculateChangedBits(props, Component) : 1073741823), - (needsContext |= 0), - 0 === needsContext) + (Component |= 0), + 0 === Component) ) { if ( unmaskedContext.children === fn.children && @@ -4065,10 +4067,10 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { propagateContextChange( workInProgress, updateExpirationTime, - needsContext, + Component, renderExpirationTime ); - workInProgress.stateNode = needsContext; + workInProgress.stateNode = Component; pushProvider(workInProgress); reconcileChildren( current$$1,