From bd09b73e356e6148dd4ebd3b598904ccae774d2b Mon Sep 17 00:00:00 2001 From: zombieJ Date: Thu, 7 Sep 2017 17:07:34 +0800 Subject: [PATCH 1/2] add pendingProps arg --- src/renderers/shared/fiber/ReactChildFiber.js | 5 ++--- src/renderers/shared/fiber/ReactFiber.js | 3 ++- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/renderers/shared/fiber/ReactChildFiber.js b/src/renderers/shared/fiber/ReactChildFiber.js index 655e2a1e85d..a9bd9d11049 100644 --- a/src/renderers/shared/fiber/ReactChildFiber.js +++ b/src/renderers/shared/fiber/ReactChildFiber.js @@ -1443,9 +1443,8 @@ exports.cloneChildFibers = function( let newChild = createWorkInProgress( currentChild, currentChild.pendingWorkPriority, + currentChild.pendingProps, ); - // TODO: Pass this as an argument, since it's easy to forget. - newChild.pendingProps = currentChild.pendingProps; workInProgress.child = newChild; newChild.return = workInProgress; @@ -1454,8 +1453,8 @@ exports.cloneChildFibers = function( newChild = newChild.sibling = createWorkInProgress( currentChild, currentChild.pendingWorkPriority, + currentChild.pendingProps, ); - newChild.pendingProps = currentChild.pendingProps; newChild.return = workInProgress; } newChild.sibling = null; diff --git a/src/renderers/shared/fiber/ReactFiber.js b/src/renderers/shared/fiber/ReactFiber.js index 2a07cf2dc63..a64030fc684 100644 --- a/src/renderers/shared/fiber/ReactFiber.js +++ b/src/renderers/shared/fiber/ReactFiber.js @@ -237,6 +237,7 @@ function shouldConstruct(Component) { exports.createWorkInProgress = function( current: Fiber, renderPriority: PriorityLevel, + pendingProps: any, ): Fiber { let workInProgress = current.alternate; if (workInProgress === null) { @@ -281,7 +282,7 @@ exports.createWorkInProgress = function( workInProgress.updateQueue = current.updateQueue; // pendingProps is set by the parent during reconciliation. - // TODO: Pass this as an argument. + workInProgress.pendingProps = pendingProps; // These will be overridden during the parent's reconciliation workInProgress.sibling = current.sibling; From 2508d11b9f401d107ec27db9fb097d54ae61e648 Mon Sep 17 00:00:00 2001 From: zombieJ Date: Wed, 13 Sep 2017 19:12:45 +0800 Subject: [PATCH 2/2] pass null for pendingProps if empty --- src/renderers/shared/fiber/ReactChildFiber.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/renderers/shared/fiber/ReactChildFiber.js b/src/renderers/shared/fiber/ReactChildFiber.js index a9bd9d11049..69c0058cdaa 100644 --- a/src/renderers/shared/fiber/ReactChildFiber.js +++ b/src/renderers/shared/fiber/ReactChildFiber.js @@ -288,7 +288,7 @@ function ChildReconciler(shouldClone, shouldTrackSideEffects) { // We currently set sibling to null and index to 0 here because it is easy // to forget to do before returning it. E.g. for the single child case. if (shouldClone) { - const clone = createWorkInProgress(fiber, priority); + const clone = createWorkInProgress(fiber, priority, null); clone.index = 0; clone.sibling = null; return clone;