@samitouri / QOS-React / commits / 5f49b63bde

Move setState callback to right after didUpdate (#8204)

It's much easier to do it this way in Fiber and there shouldn't be much observable difference.

Ben Alpert committed Nov 5, 2016 at 14:37 UTC 5f49b63bde09567fb3d52a13e3e264dfcda5cac6
4 files changed +8 -20
scripts/fiber/tests-failing.txt
-1
@@ -575,7 +575,6 @@ src/renderers/shared/stack/reconciler/__tests__/ReactUpdates-test.js
575 * should flow updates correctly
576 * should share reconcile transaction across different roots
577 * should queue mount-ready handlers across different roots
578 -* should flush updates in the correct order
578 * should flush updates in the correct order across roots
579 * should queue updates from during mount
580 * calls asap callbacks properly
scripts/fiber/tests-passing.txt
+1
@@ -1165,6 +1165,7 @@ src/renderers/shared/stack/reconciler/__tests__/ReactStatelessComponent-test.js
1165
1166 src/renderers/shared/stack/reconciler/__tests__/ReactUpdates-test.js
1167 * should not reconcile children passed via props
1168 +* should flush updates in the correct order
1169 * should queue nested updates
1170 * calls componentWillReceiveProps setState callback properly
1171 * does not update one component twice in a batch (#2410)
src/renderers/shared/stack/reconciler/ReactUpdates.js
+2 -14
@@ -53,21 +53,11 @@ var NESTED_UPDATES = {
53 },
54 };
55
56 -var UPDATE_QUEUEING = {
57 - initialize: function() {
58 - this.callbackQueue.reset();
59 - },
60 - close: function() {
61 - this.callbackQueue.notifyAll();
62 - },
63 -};
64 -
65 -var TRANSACTION_WRAPPERS = [NESTED_UPDATES, UPDATE_QUEUEING];
56 +var TRANSACTION_WRAPPERS = [NESTED_UPDATES];
57
58 function ReactUpdatesFlushTransaction() {
59 this.reinitializeTransaction();
60 this.dirtyComponentsLength = null;
70 - this.callbackQueue = CallbackQueue.getPooled();
61 this.reconcileTransaction = ReactUpdates.ReactReconcileTransaction.getPooled(
62 /* useCreateElement */ true
63 );
@@ -83,8 +73,6 @@ Object.assign(
73
74 destructor: function() {
75 this.dirtyComponentsLength = null;
86 - CallbackQueue.release(this.callbackQueue);
87 - this.callbackQueue = null;
76 ReactUpdates.ReactReconcileTransaction.release(this.reconcileTransaction);
77 this.reconcileTransaction = null;
78 },
@@ -179,7 +167,7 @@ function runBatchedUpdates(transaction) {
167
168 if (callbacks) {
169 for (var j = 0; j < callbacks.length; j++) {
182 - transaction.callbackQueue.enqueue(
170 + transaction.reconcileTransaction.getReactMountReady().enqueue(
171 callbacks[j],
172 component.getPublicInstance()
173 );
src/renderers/shared/stack/reconciler/__tests__/ReactUpdates-test.js
+5 -5
@@ -634,8 +634,8 @@ describe('ReactUpdates', () => {
634 'Inner-setState-1',
635 'Inner-render-1-1',
636 'Inner-didUpdate-1-1',
637 - 'Inner-callback-1',
638 - 'Outer-callback-1',
637 + 'Inner-callback-1',
638 + 'Outer-callback-1',
639
640 'Outer-setState-2',
641 'Outer-render-2',
@@ -643,10 +643,10 @@ describe('ReactUpdates', () => {
643 'Inner-didUpdate-2-1',
644 'Outer-didUpdate-2',
645 'Inner-setState-2',
646 - 'Inner-render-2-2',
647 - 'Inner-didUpdate-2-2',
646 + 'Outer-callback-2',
647 + 'Inner-render-2-2',
648 + 'Inner-didUpdate-2-2',
649 'Inner-callback-2',
649 - 'Outer-callback-2',
650 ]);
651 /* eslint-enable indent */
652 });