File tree Expand file tree Collapse file tree 1 file changed +4
-1
lines changed Expand file tree Collapse file tree 1 file changed +4
-1
lines changed Original file line number Diff line number Diff line change @@ -94,6 +94,7 @@ export function Router(props) {
94
94
const { url, query, wasPush, path } = useLocation ( ) ;
95
95
const { rest = path , params = { } } = useContext ( RouteContext ) ;
96
96
97
+ const isLoading = useRef ( false ) ;
97
98
// Monotonic counter used to check if an un-suspending route is still the current route:
98
99
const count = useRef ( 0 ) ;
99
100
// The current route:
@@ -140,6 +141,7 @@ export function Router(props) {
140
141
141
142
// Fire an event saying we're waiting for the route:
142
143
if ( props . onLoadStart ) props . onLoadStart ( url ) ;
144
+ isLoading . current = true ;
143
145
144
146
// Re-render on unsuspend:
145
147
let c = count . current ;
@@ -176,7 +178,8 @@ export function Router(props) {
176
178
177
179
// The route is loaded and rendered.
178
180
if ( wasPush ) scrollTo ( 0 , 0 ) ;
179
- if ( props . onLoadEnd ) props . onLoadEnd ( url ) ;
181
+ if ( props . onLoadEnd && isLoading . current ) props . onLoadEnd ( url ) ;
182
+ isLoading . current = false ;
180
183
} ) ;
181
184
182
185
// Note: curChildren MUST render first in order to set didSuspend & prev.
You can’t perform that action at this time.
0 commit comments