mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
Call callbacks from setState in component context
This is way more useful than the alternative.
This commit is contained in:
@@ -54,7 +54,7 @@ function batchedUpdates(callback) {
|
||||
component.performUpdateIfNecessary();
|
||||
if (callbacks) {
|
||||
for (var j = 0; j < callbacks.length; j++) {
|
||||
callbacks[j]();
|
||||
callbacks[j].call(component);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -237,6 +237,7 @@ describe('ReactUpdates', function() {
|
||||
ReactUpdates.batchedUpdates(function() {
|
||||
instance.setState({x: 1}, function() {
|
||||
instance.setState({x: 2}, function() {
|
||||
expect(this).toBe(instance);
|
||||
innerCallbackRun = true;
|
||||
expect(instance.state.x).toBe(2);
|
||||
expect(updateCount).toBe(2);
|
||||
|
||||
Reference in New Issue
Block a user