Skip to content

Commit

Permalink
Move setState callback to right after didUpdate (#8204)
Browse files Browse the repository at this point in the history
It's much easier to do it this way in Fiber and there shouldn't be much observable difference.
  • Loading branch information
sophiebits authored Nov 5, 2016
1 parent ba6b53a commit 5f49b63
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 20 deletions.
1 change: 0 additions & 1 deletion scripts/fiber/tests-failing.txt
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,6 @@ src/renderers/shared/stack/reconciler/__tests__/ReactUpdates-test.js
* should flow updates correctly
* should share reconcile transaction across different roots
* should queue mount-ready handlers across different roots
* should flush updates in the correct order
* should flush updates in the correct order across roots
* should queue updates from during mount
* calls asap callbacks properly
Expand Down
1 change: 1 addition & 0 deletions scripts/fiber/tests-passing.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1165,6 +1165,7 @@ src/renderers/shared/stack/reconciler/__tests__/ReactStatelessComponent-test.js

src/renderers/shared/stack/reconciler/__tests__/ReactUpdates-test.js
* should not reconcile children passed via props
* should flush updates in the correct order
* should queue nested updates
* calls componentWillReceiveProps setState callback properly
* does not update one component twice in a batch (#2410)
Expand Down
16 changes: 2 additions & 14 deletions src/renderers/shared/stack/reconciler/ReactUpdates.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,21 +53,11 @@ var NESTED_UPDATES = {
},
};

var UPDATE_QUEUEING = {
initialize: function() {
this.callbackQueue.reset();
},
close: function() {
this.callbackQueue.notifyAll();
},
};

var TRANSACTION_WRAPPERS = [NESTED_UPDATES, UPDATE_QUEUEING];
var TRANSACTION_WRAPPERS = [NESTED_UPDATES];

function ReactUpdatesFlushTransaction() {
this.reinitializeTransaction();
this.dirtyComponentsLength = null;
this.callbackQueue = CallbackQueue.getPooled();
this.reconcileTransaction = ReactUpdates.ReactReconcileTransaction.getPooled(
/* useCreateElement */ true
);
Expand All @@ -83,8 +73,6 @@ Object.assign(

destructor: function() {
this.dirtyComponentsLength = null;
CallbackQueue.release(this.callbackQueue);
this.callbackQueue = null;
ReactUpdates.ReactReconcileTransaction.release(this.reconcileTransaction);
this.reconcileTransaction = null;
},
Expand Down Expand Up @@ -179,7 +167,7 @@ function runBatchedUpdates(transaction) {

if (callbacks) {
for (var j = 0; j < callbacks.length; j++) {
transaction.callbackQueue.enqueue(
transaction.reconcileTransaction.getReactMountReady().enqueue(
callbacks[j],
component.getPublicInstance()
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -634,19 +634,19 @@ describe('ReactUpdates', () => {
'Inner-setState-1',
'Inner-render-1-1',
'Inner-didUpdate-1-1',
'Inner-callback-1',
'Outer-callback-1',
'Inner-callback-1',
'Outer-callback-1',

'Outer-setState-2',
'Outer-render-2',
'Inner-render-2-1',
'Inner-didUpdate-2-1',
'Outer-didUpdate-2',
'Inner-setState-2',
'Inner-render-2-2',
'Inner-didUpdate-2-2',
'Outer-callback-2',
'Inner-render-2-2',
'Inner-didUpdate-2-2',
'Inner-callback-2',
'Outer-callback-2',
]);
/* eslint-enable indent */
});
Expand Down

0 comments on commit 5f49b63

Please sign in to comment.