Skip to content

Commit 6d5a78e

Browse files
committed
fix Transitioner
1 parent 90bda4c commit 6d5a78e

File tree

1 file changed

+5
-29
lines changed

1 file changed

+5
-29
lines changed

packages/solid-router/src/Transitioner.tsx

Lines changed: 5 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as Solid from 'solid-js'
2-
import { trimPathRight } from '@tanstack/router-core'
2+
import { getLocationChangeInfo, trimPathRight } from '@tanstack/router-core'
33
import { usePrevious } from './utils'
44
import { useRouter } from './useRouter'
55
import { useRouterState } from './useRouterState'
@@ -90,17 +90,9 @@ export function Transitioner() {
9090
() => isLoading(),
9191
(isLoading, previousIsLoading) => {
9292
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-
9893
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),
10496
})
10597
}
10698
},
@@ -112,17 +104,9 @@ export function Transitioner() {
112104
(isPagePending, previousIsPagePending) => {
113105
// emit onBeforeRouteMount
114106
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-
120107
router.emit({
121108
type: 'onBeforeRouteMount',
122-
fromLocation,
123-
toLocation,
124-
pathChanged,
125-
hrefChanged,
109+
...getLocationChangeInfo(router.state),
126110
})
127111
}
128112
},
@@ -135,17 +119,9 @@ export function Transitioner() {
135119
(isAnyPending, previousIsAnyPending) => {
136120
// The router was pending and now it's not
137121
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-
143122
router.emit({
144123
type: 'onResolved',
145-
fromLocation,
146-
toLocation,
147-
pathChanged,
148-
hrefChanged,
124+
...getLocationChangeInfo(router.state),
149125
})
150126

151127
router.__store.setState((s) => ({

0 commit comments

Comments
 (0)