The library for web and native user interfaces.
Call callbacks from setState in component context
This is way more useful than the alternative.
Ben Alpert committed
Jul 22, 2013 at 21:32 UTC
f1231e60b0fda262cb617cd73a56d1e5bdbf0778
2 files changed
+2
-1
src/core/ReactUpdates.js
+1
-1
@@ -54,7 +54,7 @@ function batchedUpdates(callback) {
54
component.performUpdateIfNecessary();
55
if (callbacks) {
56
for (var j = 0; j < callbacks.length; j++) {
57
- callbacks[j]();
57
+ callbacks[j].call(component);
58
}
59
}
60
}
src/core/__tests__/ReactUpdates-test.js
+1
@@ -237,6 +237,7 @@ describe('ReactUpdates', function() {
237
ReactUpdates.batchedUpdates(function() {
238
instance.setState({x: 1}, function() {
239
instance.setState({x: 2}, function() {
240
+ expect(this).toBe(instance);
241
innerCallbackRun = true;
242
expect(instance.state.x).toBe(2);
243
expect(updateCount).toBe(2);