Skip to content

Commit

Permalink
Fix batchedUpdates return value (#7444)
Browse files Browse the repository at this point in the history
(cherry picked from commit 7d57c1f)
  • Loading branch information
B.Orlov authored and zpao committed Oct 3, 2016
1 parent 5a540f7 commit bada298
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
Expand Up @@ -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);
}
},
};
Expand Down
2 changes: 1 addition & 1 deletion src/renderers/shared/stack/reconciler/ReactUpdates.js
Expand Up @@ -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);
}

/**
Expand Down
Expand Up @@ -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);
});
});

0 comments on commit bada298

Please sign in to comment.