Skip to content

Commit 7e8e612

Browse files
committed
Call dispatch callback in the scope of the <Routes>
1 parent 5a91ce4 commit 7e8e612

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

modules/components/Routes.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ var Routes = React.createClass({
288288
this._handleStateChange = this.handleStateChange.bind(this, path, actionType);
289289
this.setState(nextState);
290290
}
291-
}.bind(this));
291+
});
292292
},
293293

294294
handleStateChange: function (path, actionType) {
@@ -340,15 +340,16 @@ var Routes = React.createClass({
340340
toMatches = nextMatches;
341341
}
342342

343+
var callbackScope = this;
343344
var query = Path.extractQuery(path) || {};
344345

345346
runTransitionFromHooks(fromMatches, transition, function (error) {
346347
if (error || transition.isAborted)
347-
return callback(error, transition.abortReason);
348+
return callback.call(callbackScope, error, transition.abortReason);
348349

349350
runTransitionToHooks(toMatches, transition, query, function (error) {
350351
if (error || transition.isAborted)
351-
return callback(error, transition.abortReason);
352+
return callback.call(callbackScope, error, transition.abortReason);
352353

353354
var matches = currentMatches.slice(0, currentMatches.length - fromMatches.length).concat(toMatches);
354355
var rootMatch = getRootMatch(matches);
@@ -357,7 +358,7 @@ var Routes = React.createClass({
357358
return match.route;
358359
});
359360

360-
callback(null, null, {
361+
callback.call(callbackScope, null, null, {
361362
path: path,
362363
matches: matches,
363364
activeRoutes: routes,

0 commit comments

Comments
 (0)