File tree Expand file tree Collapse file tree 2 files changed +9
-2
lines changed Expand file tree Collapse file tree 2 files changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -180,7 +180,8 @@ export function Router(props) {
180
180
if ( prevRoute . current !== path ) {
181
181
if ( wasPush ) scrollTo ( 0 , 0 ) ;
182
182
if ( props . onLoadEnd && isLoading . current ) props . onLoadEnd ( url ) ;
183
- if ( props . onRouteChange && ! isLoading . current ) props . onRouteChange ( url ) ;
183
+ if ( props . onRouteChange ) props . onRouteChange ( url ) ;
184
+
184
185
isLoading . current = false ;
185
186
prevRoute . current = path ;
186
187
}
Original file line number Diff line number Diff line change @@ -28,11 +28,16 @@ describe('Router', () => {
28
28
const Profiles = jest . fn ( ( ) => html `< h1 > Profiles</ h1 > ` ) ;
29
29
const Profile = jest . fn ( ( { params } ) => html `< h1 > Profile: ${ params . id } </ h1 > ` ) ;
30
30
const Fallback = jest . fn ( ( ) => html `< h1 > Fallback</ h1 > ` ) ;
31
+ const stack = [ ] ;
31
32
let loc ;
32
33
render (
33
34
html `
34
35
< ${ LocationProvider } >
35
- < ${ Router } >
36
+ < ${ Router }
37
+ onRouteChange =${ url => {
38
+ stack . push ( url ) ;
39
+ } }
40
+ >
36
41
< ${ Home } path ="/" />
37
42
< ${ Profiles } path ="/profiles" />
38
43
< ${ Profile } path ="/profiles/:id" />
@@ -111,6 +116,7 @@ describe('Router', () => {
111
116
path : '/other' ,
112
117
query : { a : 'b' , c : 'd' }
113
118
} ) ;
119
+ expect ( stack ) . toEqual ( [ '/profiles' , '/profiles/bob' , '/other?a=b&c=d' ] ) ;
114
120
} ) ;
115
121
116
122
it ( 'should wait for asynchronous routes' , async ( ) => {
You can’t perform that action at this time.
0 commit comments