1
1
import * as Solid from 'solid-js'
2
- import { trimPathRight } from '@tanstack/router-core'
2
+ import { getLocationChangeInfo , trimPathRight } from '@tanstack/router-core'
3
3
import { usePrevious } from './utils'
4
4
import { useRouter } from './useRouter'
5
5
import { useRouterState } from './useRouterState'
@@ -90,17 +90,9 @@ export function Transitioner() {
90
90
( ) => isLoading ( ) ,
91
91
( isLoading , previousIsLoading ) => {
92
92
if ( previousIsLoading && ! isLoading ) {
93
- const toLocation = router . state . location
94
- const fromLocation = router . state . resolvedLocation
95
- const pathChanged = fromLocation . pathname !== toLocation . pathname
96
- const hrefChanged = fromLocation . href !== toLocation . href
97
-
98
93
router . emit ( {
99
- type : 'onLoad' , // When the new URL has committed, when the new matches have been loaded into state.matches
100
- fromLocation,
101
- toLocation,
102
- pathChanged,
103
- hrefChanged,
94
+ type : 'onLoad' ,
95
+ ...getLocationChangeInfo ( router . state ) ,
104
96
} )
105
97
}
106
98
} ,
@@ -112,17 +104,9 @@ export function Transitioner() {
112
104
( isPagePending , previousIsPagePending ) => {
113
105
// emit onBeforeRouteMount
114
106
if ( previousIsPagePending && ! isPagePending ) {
115
- const toLocation = router . state . location
116
- const fromLocation = router . state . resolvedLocation
117
- const pathChanged = fromLocation . pathname !== toLocation . pathname
118
- const hrefChanged = fromLocation . href !== toLocation . href
119
-
120
107
router . emit ( {
121
108
type : 'onBeforeRouteMount' ,
122
- fromLocation,
123
- toLocation,
124
- pathChanged,
125
- hrefChanged,
109
+ ...getLocationChangeInfo ( router . state ) ,
126
110
} )
127
111
}
128
112
} ,
@@ -135,17 +119,9 @@ export function Transitioner() {
135
119
( isAnyPending , previousIsAnyPending ) => {
136
120
// The router was pending and now it's not
137
121
if ( previousIsAnyPending && ! isAnyPending ) {
138
- const toLocation = router . state . location
139
- const fromLocation = router . state . resolvedLocation
140
- const pathChanged = fromLocation . pathname !== toLocation . pathname
141
- const hrefChanged = fromLocation . href !== toLocation . href
142
-
143
122
router . emit ( {
144
123
type : 'onResolved' ,
145
- fromLocation,
146
- toLocation,
147
- pathChanged,
148
- hrefChanged,
124
+ ...getLocationChangeInfo ( router . state ) ,
149
125
} )
150
126
151
127
router . __store . setState ( ( s ) => ( {
0 commit comments