Skip to content

Commit 2a75f3e

Browse files
committed
[added] query argument to willTransitionTo
Fixes #246
1 parent 4c26d1a commit 2a75f3e

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

modules/components/Routes.js

+5-4
Original file line numberDiff line numberDiff line change
@@ -329,17 +329,18 @@ function runTransitionHooks(routes, transition) {
329329
toMatches = nextMatches;
330330
}
331331

332+
var query = Path.extractQuery(transition.path) || {};
333+
332334
return runTransitionFromHooks(fromMatches, transition).then(function () {
333335
if (transition.isAborted)
334336
return; // No need to continue.
335337

336-
return runTransitionToHooks(toMatches, transition).then(function () {
338+
return runTransitionToHooks(toMatches, transition, query).then(function () {
337339
if (transition.isAborted)
338340
return; // No need to continue.
339341

340342
var rootMatch = getRootMatch(nextMatches);
341343
var params = (rootMatch && rootMatch.params) || {};
342-
var query = Path.extractQuery(transition.path) || {};
343344

344345
return {
345346
path: transition.path,
@@ -380,15 +381,15 @@ function runTransitionFromHooks(matches, transition) {
380381
* with the transition object and any params that apply to that handler. Returns
381382
* a promise that resolves after the last handler.
382383
*/
383-
function runTransitionToHooks(matches, transition) {
384+
function runTransitionToHooks(matches, transition, query) {
384385
var promise = Promise.resolve();
385386

386387
matches.forEach(function (match) {
387388
promise = promise.then(function () {
388389
var handler = match.route.props.handler;
389390

390391
if (!transition.isAborted && handler.willTransitionTo)
391-
return handler.willTransitionTo(transition, match.params);
392+
return handler.willTransitionTo(transition, match.params, query);
392393
});
393394
});
394395

0 commit comments

Comments
 (0)