Call callbacks from setState in component context

This is way more useful than the alternative.
This commit is contained in:
Ben Alpert
2013-07-22 21:32:46 -05:00
parent d9aa2bd12c
commit f1231e60b0
2 changed files with 2 additions and 1 deletions
+1 -1
View File
@@ -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);
}
}
}
+1
View File
@@ -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);