@samitouri / QOS-React / commits / 3121e051a8

At the end of a batch, perform any sync work that was scheduled

Andrew Clark committed Oct 31, 2016 at 09:59 UTC 3121e051a849b1d1e497de3362b3d4bc317b902d
1 file changed +10 -2
src/renderers/shared/fiber/ReactFiberScheduler.js
+10 -2
@@ -506,10 +506,14 @@ module.exports = function<T, P, I, TI, C>(config : HostConfig<T, P, I, TI, C>) {
506 }
507
508 function performSynchronousWork() {
509 + const prev = shouldBatchUpdates;
510 + shouldBatchUpdates = true;
511 // All nested updates are batched
510 - batchedUpdates(() => {
512 + try {
513 performAndHandleErrors(performSynchronousWorkUnsafe);
512 - });
514 + } finally {
515 + shouldBatchUpdates = prev;
516 + }
517 }
518
519 function scheduleSynchronousWork(root : FiberRoot) {
@@ -688,6 +692,10 @@ module.exports = function<T, P, I, TI, C>(config : HostConfig<T, P, I, TI, C>) {
692 return fn();
693 } finally {
694 shouldBatchUpdates = prev;
695 + // If we've exited the batch, perform any scheduled sync work
696 + if (!shouldBatchUpdates) {
697 + performSynchronousWork();
698 + }
699 }
700 }
701