Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions packages/solid-router/src/link.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -122,16 +122,20 @@ export function useLinkProps<
'unsafeRelative',
])

const currentLocation = Solid.createMemo(() => router.stores.location.state)
const currentSearch = Solid.createMemo(
() => router.stores.location.state.searchStr,
const buildLocationKey = Solid.createMemo(
() =>
router.stores.lastMatchId.state +
'\0' +
router.stores.location.state.hash +
'\0' +
router.stores.location.state.searchStr,
)

const _options = () => options

const next = Solid.createMemo(() => {
// rebuild location when search changes
currentSearch()
// Rebuild when inherited search/hash or the current route context changes.
buildLocationKey()
const options = _options() as any
// untrack because router-core will also access stores, which are signals in solid
return Solid.untrack(() => router.buildLocation(options))
Expand Down Expand Up @@ -199,7 +203,7 @@ export function useLinkProps<
const isActive = Solid.createMemo(() => {
if (externalLink()) return false
const activeOptions = local.activeOptions
const current = currentLocation()
const current = router.stores.location.state
const nextLocation = next()

if (activeOptions?.exact) {
Expand Down
12 changes: 11 additions & 1 deletion packages/vue-router/src/link.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,14 @@ export function useLinkProps<
(location) => location.searchStr,
{ equal: Object.is },
)
const currentHash = useStore(
router.stores.location,
(location) => location.hash,
{
equal: Object.is,
},
)
const currentLeafMatchId = useStore(router.stores.lastMatchId, (id) => id)
const from = options.from
? Vue.computed(() => options.from)
: useStore(router.stores.lastMatchRouteFullPath, (fullPath) => fullPath)
Expand All @@ -229,8 +237,10 @@ export function useLinkProps<
}))

const next = Vue.computed(() => {
// Depend on search to rebuild when search changes
// Rebuild when inherited search/hash or the current route context changes.
currentSearch.value
currentHash.value
currentLeafMatchId.value
return router.buildLocation(_options.value as any)
})

Expand Down
Loading