Reset invalid UpdateQueue fields when cloning from current
Similar to what cloneFiber does. No change in behavior, but it's more consistent this way.
Andrew Clark committed
Jan 9, 2017 at 17:14 UTC
288a4c4d6db841da0afe99d057fddf151c339ddb
2 files changed
+16
-12
src/renderers/shared/fiber/ReactFiber.js
+1
-1
@@ -277,7 +277,7 @@ exports.cloneFiber = function(fiber : Fiber, priorityLevel : PriorityLevel) : Fi
277
// pendingProps is here for symmetry but is unnecessary in practice for now.
278
// TODO: Pass in the new pendingProps as an argument maybe?
279
alt.pendingProps = fiber.pendingProps;
280
- cloneUpdateQueue(alt, fiber);
280
+ cloneUpdateQueue(fiber, alt);
281
alt.pendingWorkPriority = priorityLevel;
282
283
alt.memoizedProps = fiber.memoizedProps;
src/renderers/shared/fiber/ReactFiberUpdateQueue.js
+15
-11
@@ -113,21 +113,25 @@ function ensureUpdateQueue(fiber : Fiber) : UpdateQueue {
113
}
114
115
// Clones an update queue from a source fiber onto its alternate.
116
-function cloneUpdateQueue(alt : Fiber, fiber : Fiber) : UpdateQueue | null {
117
- const sourceQueue = fiber.updateQueue;
118
- if (!sourceQueue) {
116
+function cloneUpdateQueue(current : Fiber, workInProgress : Fiber) : UpdateQueue | null {
117
+ const currentQueue = current.updateQueue;
118
+ if (!currentQueue) {
119
// The source fiber does not have an update queue.
120
- alt.updateQueue = null;
120
+ workInProgress.updateQueue = null;
121
return null;
122
}
123
// If the alternate already has a queue, reuse the previous object.
124
- const altQueue = alt.updateQueue || {};
125
- altQueue.first = sourceQueue.first;
126
- altQueue.last = sourceQueue.last;
127
- altQueue.hasForceUpdate = sourceQueue.hasForceUpdate;
128
- altQueue.callbackList = sourceQueue.callbackList;
129
- altQueue.isProcessing = sourceQueue.isProcessing;
130
- alt.updateQueue = altQueue;
124
+ const altQueue = workInProgress.updateQueue || {};
125
+ altQueue.first = currentQueue.first;
126
+ altQueue.last = currentQueue.last;
127
+
128
+ // These fields are invalid by the time we clone from current. Reset them.
129
+ altQueue.hasForceUpdate = false;
130
+ altQueue.callbackList = null;
131
+ altQueue.isProcessing = false;
132
+
133
+ workInProgress.updateQueue = altQueue;
134
+
135
return altQueue;
136
}
137
exports.cloneUpdateQueue = cloneUpdateQueue;