Call callbacks from setState in component context

This is way more useful than the alternative.
This commit is contained in:
Ben Alpert committed 2013-07-22 23:47:07 -05:00
1 parent d9aa2bd12c
commit f1231e60b0
2 files changed
+2 -1

No files matched your search

+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);