diff --git a/scripts/fiber/tests-failing.txt b/scripts/fiber/tests-failing.txt index 9a70a61d8faad..e31c3ad8be2dd 100644 --- a/scripts/fiber/tests-failing.txt +++ b/scripts/fiber/tests-failing.txt @@ -6,9 +6,6 @@ src/addons/__tests__/ReactFragment-test.js * should throw if a plain object even if it is in an owner * should throw if a plain object looks like an old element -src/isomorphic/classic/__tests__/ReactContextValidator-test.js -* should pass previous context to lifecycles - src/isomorphic/classic/element/__tests__/ReactElementValidator-test.js * includes the owner name when passing null, undefined, boolean, or number diff --git a/scripts/fiber/tests-passing.txt b/scripts/fiber/tests-passing.txt index cc1e1ff464889..0dacaf39c2946 100644 --- a/scripts/fiber/tests-passing.txt +++ b/scripts/fiber/tests-passing.txt @@ -153,6 +153,7 @@ src/isomorphic/children/__tests__/sliceChildren-test.js src/isomorphic/classic/__tests__/ReactContextValidator-test.js * should filter out context not in contextTypes * should pass next context to lifecycles +* should pass previous context to lifecycles * should check context types * should check child context types diff --git a/src/renderers/shared/fiber/ReactFiber.js b/src/renderers/shared/fiber/ReactFiber.js index 26c8efa50700f..83b8f68a47736 100644 --- a/src/renderers/shared/fiber/ReactFiber.js +++ b/src/renderers/shared/fiber/ReactFiber.js @@ -112,6 +112,9 @@ export type Fiber = { // The state used to create the output memoizedState: any, + // The context used to create the output; stored for ClassComponents only + memoizedContext: any, + // Effect effectTag: TypeOfSideEffect, @@ -201,6 +204,7 @@ var createFiber = function(tag : TypeOfWork, key : null | string) : Fiber { updateQueue: null, callbackList: null, memoizedState: null, + memoizedContext: null, effectTag: NoEffect, nextEffect: null, @@ -280,6 +284,7 @@ exports.cloneFiber = function(fiber : Fiber, priorityLevel : PriorityLevel) : Fi alt.memoizedProps = fiber.memoizedProps; alt.memoizedState = fiber.memoizedState; + alt.memoizedContext = fiber.memoizedContext; if (__DEV__) { alt._debugID = fiber._debugID; diff --git a/src/renderers/shared/fiber/ReactFiberCommitWork.js b/src/renderers/shared/fiber/ReactFiberCommitWork.js index 879fcf2485ee7..c0a1f28b39a50 100644 --- a/src/renderers/shared/fiber/ReactFiberCommitWork.js +++ b/src/renderers/shared/fiber/ReactFiberCommitWork.js @@ -412,7 +412,8 @@ module.exports = function( if (typeof instance.componentDidUpdate === 'function') { const prevProps = current.memoizedProps; const prevState = current.memoizedState; - instance.componentDidUpdate(prevProps, prevState); + const prevContext = current.memoizedContext; + instance.componentDidUpdate(prevProps, prevState, prevContext); } } attachRef(current, finishedWork, instance); diff --git a/src/renderers/shared/fiber/ReactFiberCompleteWork.js b/src/renderers/shared/fiber/ReactFiberCompleteWork.js index c0f41ab4c872f..10027db815742 100644 --- a/src/renderers/shared/fiber/ReactFiberCompleteWork.js +++ b/src/renderers/shared/fiber/ReactFiberCompleteWork.js @@ -182,6 +182,7 @@ module.exports = function( const instance = workInProgress.stateNode; workInProgress.memoizedState = instance.state; workInProgress.memoizedProps = instance.props; + workInProgress.memoizedContext = instance.context; return null; }