@@ -11,6 +11,7 @@ export default class BrowserRouter extends Router {
11
11
super ( props ) ;
12
12
this . history = props . history ;
13
13
this . stateFromServer = null ;
14
+ this . __CTX__ = null ;
14
15
if ( window && '__REACT_ROUTER_ASYNC__' in window ) {
15
16
this . stateFromServer = window [ '__REACT_ROUTER_ASYNC__' ] . state ;
16
17
if ( this . stateFromServer . error !== null ) {
@@ -42,12 +43,17 @@ export default class BrowserRouter extends Router {
42
43
const { redirect, error } = await this . router . resolve ( { path, ctx } ) ;
43
44
if ( error === null ) {
44
45
if ( redirect ) {
45
- this . history . push ( redirect , { ctx } ) ;
46
+ this . __CTX__ = ctx ;
47
+ this . history . push ( redirect ) ;
46
48
} else {
47
- this . history . push ( path , { ctx } ) ;
49
+ this . __CTX__ = ctx ;
50
+ this . history . push ( path ) ;
48
51
}
49
52
} else {
50
- if ( error . message !== 'Cancelled' ) this . history . push ( path ) ;
53
+ if ( error . message !== 'Cancelled' ) {
54
+ this . __CTX__ = ctx ;
55
+ this . history . push ( path ) ;
56
+ }
51
57
}
52
58
}
53
59
async push ( path , ctx = new Context ( ) ) {
@@ -75,7 +81,10 @@ export default class BrowserRouter extends Router {
75
81
if ( this . router . isRunning ) this . router . cancel ( ) ;
76
82
const currentTransition = this . router . currentTransition ;
77
83
let opts = { path, ctx : new Context ( ) } ;
78
- if ( state && state . ctx ) opts . ctx = state . ctx ;
84
+ if ( this . __CTX__ ) {
85
+ opts . ctx = this . __CTX__ ;
86
+ this . __CTX__ = null ;
87
+ }
79
88
let { location, route, status, params, redirect, result, ctx, error } = await this . router . run ( opts ) ;
80
89
if ( error && error . message === 'Cancelled' ) return ;
81
90
if ( error !== null && error . message !== 'Cancelled' ) {
0 commit comments