Skip to content

Commit

Permalink
Merge pull request #224 from spicyj/cb-context
Browse files Browse the repository at this point in the history
Call callbacks from setState in component context
  • Loading branch information
zpao committed Jul 25, 2013
2 parents bdf2a9b + f1231e6 commit a41aa76
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/core/ReactUpdates.js
Expand Up @@ -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);
}
}
}
Expand Down
1 change: 1 addition & 0 deletions src/core/__tests__/ReactUpdates-test.js
Expand Up @@ -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);
Expand Down

0 comments on commit a41aa76

Please sign in to comment.