@@ -42,9 +42,9 @@ export default class BrowserRouter extends Router {
42
42
const { redirect, error } = await this . router . resolve ( { path, ctx } ) ;
43
43
if ( error === null ) {
44
44
if ( redirect ) {
45
- this . history . push ( redirect ) ;
45
+ this . history . push ( redirect , { ctx } ) ;
46
46
} else {
47
- this . history . push ( path ) ;
47
+ this . history . push ( path , { ctx } ) ;
48
48
}
49
49
} else {
50
50
if ( error . message !== 'Cancelled' ) this . history . push ( path ) ;
@@ -70,11 +70,13 @@ export default class BrowserRouter extends Router {
70
70
go ( n ) {
71
71
this . history . go ( n ) ;
72
72
}
73
- private _locationChanged = async ( { pathname, hash, search } , historyAction ) => {
73
+ private _locationChanged = async ( { pathname, hash, search, state } , historyAction ) => {
74
74
const path = pathname + search + hash ;
75
75
if ( this . router . isRunning ) this . router . cancel ( ) ;
76
76
const currentTransition = this . router . currentTransition ;
77
- let { location, route, status, params, redirect, result, ctx, error } = await this . router . run ( { path } ) ;
77
+ let opts = { path, ctx : new Context ( ) } ;
78
+ if ( state . ctx ) opts . ctx = state . ctx ;
79
+ let { location, route, status, params, redirect, result, ctx, error } = await this . router . run ( opts ) ;
78
80
if ( error && error . message === 'Cancelled' ) return ;
79
81
if ( error !== null && error . message !== 'Cancelled' ) {
80
82
result = Router . getErrorComponent ( error , this . errors ) ;
0 commit comments