@samitouri / QOS-React / commits / 7d57c1f0c1

Fix batchedUpdates return value (#7444)

B.Orlov committed Aug 9, 2016 at 21:26 UTC 7d57c1f0c17eff5aa868791a7496cecd2f7ca392
3 files changed +9 -3
src/renderers/shared/stack/reconciler/ReactDefaultBatchingStrategy.js
+2 -2
@@ -60,9 +60,9 @@ var ReactDefaultBatchingStrategy = {
60
61 // The code is written this way to avoid extra allocations
62 if (alreadyBatchingUpdates) {
63 - callback(a, b, c, d, e);
63 + return callback(a, b, c, d, e);
64 } else {
65 - transaction.perform(callback, null, a, b, c, d, e);
65 + return transaction.perform(callback, null, a, b, c, d, e);
66 }
67 },
68 };
src/renderers/shared/stack/reconciler/ReactUpdates.js
+1 -1
@@ -108,7 +108,7 @@ PooledClass.addPoolingTo(ReactUpdatesFlushTransaction);
108
109 function batchedUpdates(callback, a, b, c, d, e) {
110 ensureInjected();
111 - batchingStrategy.batchedUpdates(callback, a, b, c, d, e);
111 + return batchingStrategy.batchedUpdates(callback, a, b, c, d, e);
112 }
113
114 /**
src/renderers/shared/stack/reconciler/__tests__/ReactUpdates-test.js
+6
@@ -1147,4 +1147,10 @@ describe('ReactUpdates', function() {
1147 ReactDOM.render(<App />, document.createElement('div'));
1148 });
1149
1150 + it('unstable_batchedUpdates should return value from a callback', function() {
1151 + var result = ReactDOM.unstable_batchedUpdates(function() {
1152 + return 42;
1153 + });
1154 + expect(result).toEqual(42);
1155 + });
1156 });