Add bailout to HostRoot
This doesn't need to compare props because it doesn't use props, only state.
Sebastian Markbage committed
Dec 21, 2016 at 11:34 UTC
0907a49abd709308e95a93e11dde16d67c06dd43
1 file changed
+8
-1
src/renderers/shared/fiber/ReactFiberBeginWork.js
+8
-1
@@ -267,11 +267,18 @@ module.exports = function<T, P, I, TI, C, CX>(
267
if (updateQueue) {
268
const prevState = workInProgress.memoizedState;
269
const state = beginUpdateQueue(workInProgress, updateQueue, null, prevState, null, priorityLevel);
270
+ if (prevState === state) {
271
+ // If the state is the same as before, that's a bailout because we had
272
+ // no work matching this priority.
273
+ return bailoutOnAlreadyFinishedWork(current, workInProgress);
274
+ }
275
const element = state.element;
276
reconcileChildren(current, workInProgress, element);
277
workInProgress.memoizedState = state;
278
+ return workInProgress.child;
279
}
274
- return workInProgress.child;
280
+ // If there is no update queue, that's a bailout because the root has no props.
281
+ return bailoutOnAlreadyFinishedWork(current, workInProgress);
282
}
283
284
function updateHostComponent(current, workInProgress) {