Fix batchedUpdates return value (#7444)

This commit is contained in:
B.Orlov
2016-08-09 10:26:29 -07:00
committed by Ben Alpert
parent 43674d989d
commit 7d57c1f0c1
3 changed files with 9 additions and 3 deletions
@@ -60,9 +60,9 @@ var ReactDefaultBatchingStrategy = {
// The code is written this way to avoid extra allocations
if (alreadyBatchingUpdates) {
callback(a, b, c, d, e);
return callback(a, b, c, d, e);
} else {
transaction.perform(callback, null, a, b, c, d, e);
return transaction.perform(callback, null, a, b, c, d, e);
}
},
};
@@ -108,7 +108,7 @@ PooledClass.addPoolingTo(ReactUpdatesFlushTransaction);
function batchedUpdates(callback, a, b, c, d, e) {
ensureInjected();
batchingStrategy.batchedUpdates(callback, a, b, c, d, e);
return batchingStrategy.batchedUpdates(callback, a, b, c, d, e);
}
/**
@@ -1147,4 +1147,10 @@ describe('ReactUpdates', function() {
ReactDOM.render(<App />, document.createElement('div'));
});
it('unstable_batchedUpdates should return value from a callback', function() {
var result = ReactDOM.unstable_batchedUpdates(function() {
return 42;
});
expect(result).toEqual(42);
});
});