@@ -75,22 +75,7 @@ function hasMatch(matches, match) {
75
75
* callback(error, nextState) when finished. Also runs all
76
76
* transition hooks along the way.
77
77
*/
78
- function computeNextState ( component , transition , callback ) {
79
- if ( component . state . path === transition . path )
80
- return callback ( ) ; // Nothing to do!
81
-
82
- var currentMatches = component . state . matches ;
83
- var nextMatches = component . match ( transition . path ) ;
84
-
85
- warning (
86
- nextMatches ,
87
- 'No route matches path "' + transition . path + '". Make sure you have ' +
88
- '<Route path="' + transition . path + '"> somewhere in your routes'
89
- ) ;
90
-
91
- if ( ! nextMatches )
92
- nextMatches = [ ] ;
93
-
78
+ function computeNextState ( currentMatches , nextMatches , transition , callback ) {
94
79
var fromMatches , toMatches ;
95
80
if ( currentMatches . length ) {
96
81
fromMatches = currentMatches . filter ( function ( match ) {
@@ -354,9 +339,20 @@ var Routes = React.createClass({
354
339
* the transition. To resolve asynchronously, they may use transition.wait(promise).
355
340
*/
356
341
dispatch : function ( path , callback ) {
342
+ if ( this . state . path === path )
343
+ return callback ( ) ; // Nothing to do!
344
+
357
345
var transition = new Transition ( this , path ) ;
346
+ var currentMatches = this . state . matches || [ ] ;
347
+ var nextMatches = this . match ( path ) || [ ] ;
348
+
349
+ warning (
350
+ nextMatches ,
351
+ 'No route matches path "%s". Make sure you have <Route path="%s"> somewhere in your routes' ,
352
+ path , path
353
+ ) ;
358
354
359
- computeNextState ( this , transition , function ( error , nextState ) {
355
+ computeNextState ( currentMatches , nextMatches , transition , function ( error , nextState ) {
360
356
if ( error || transition . isAborted || nextState == null )
361
357
return callback ( error , transition . abortReason ) ;
362
358
0 commit comments