Skip to content

Commit 9c46060

Browse files
ci: apply automated fixes
1 parent 29dfcf9 commit 9c46060

File tree

2 files changed

+30
-14
lines changed

2 files changed

+30
-14
lines changed

packages/react-router/src/useActiveLocation.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,22 @@ export type UseActiveLocationResult = {
1111
setActiveLocation: (location?: ParsedLocation) => void
1212
}
1313

14-
export const useActiveLocation = (location?: ParsedLocation): UseActiveLocationResult => {
14+
export const useActiveLocation = (
15+
location?: ParsedLocation,
16+
): UseActiveLocationResult => {
1517
const router = useRouter()
16-
const routerLocation = useRouterState({select: (state) => state.location})
17-
const [activeLocation, setActiveLocation] = useState<ParsedLocation>(location ?? routerLocation)
18-
const [customActiveLocation, setCustomActiveLocation] = useState<ParsedLocation | undefined>(location)
18+
const routerLocation = useRouterState({ select: (state) => state.location })
19+
const [activeLocation, setActiveLocation] = useState<ParsedLocation>(
20+
location ?? routerLocation,
21+
)
22+
const [customActiveLocation, setCustomActiveLocation] = useState<
23+
ParsedLocation | undefined
24+
>(location)
1925

2026
useEffect(() => {
2127
setActiveLocation(customActiveLocation ?? routerLocation)
2228
}, [routerLocation, customActiveLocation])
2329

24-
2530
const currentRouteMatch = useMatch({
2631
strict: false,
2732
select: (match) => match,

packages/solid-router/src/useActiveLocation.ts

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { last } from '@tanstack/router-core'
2-
import { createEffect, createMemo, createSignal } from 'solid-js'
2+
import { createEffect, createMemo, createSignal } from 'solid-js'
33
import { useMatch } from './useMatch'
44
import { useRouter } from './useRouter'
55
import { useRouterState } from './useRouterState'
6-
import type {Accessor} from 'solid-js';
6+
import type { Accessor } from 'solid-js'
77
import type { ParsedLocation } from '@tanstack/router-core'
88

99
export type UseLocationResult = {
@@ -12,14 +12,22 @@ export type UseLocationResult = {
1212
setActiveLocation: (location?: ParsedLocation) => void
1313
}
1414

15-
export function useActiveLocation(location?: ParsedLocation): UseLocationResult {
15+
export function useActiveLocation(
16+
location?: ParsedLocation,
17+
): UseLocationResult {
1618
const router = useRouter()
1719
// we are not using a variable here for router state location since we need to only calculate that if the location is not passed in. It can result in unnecessary history actions if we do that.
18-
const [activeLocation, setActiveLocation] = createSignal<ParsedLocation>(location ?? useRouterState({select: s => s.location})())
19-
const [customActiveLocation, setCustomActiveLocation] = createSignal<ParsedLocation | undefined>(location)
20+
const [activeLocation, setActiveLocation] = createSignal<ParsedLocation>(
21+
location ?? useRouterState({ select: (s) => s.location })(),
22+
)
23+
const [customActiveLocation, setCustomActiveLocation] = createSignal<
24+
ParsedLocation | undefined
25+
>(location)
2026

2127
createEffect(() => {
22-
setActiveLocation(customActiveLocation() ?? useRouterState({select: s => s.location})())
28+
setActiveLocation(
29+
customActiveLocation() ?? useRouterState({ select: (s) => s.location })(),
30+
)
2331
})
2432

2533
const currentRouteMatch = useMatch({
@@ -29,9 +37,12 @@ export function useActiveLocation(location?: ParsedLocation): UseLocationResult
2937

3038
const getFromPath = (from?: string) =>
3139
createMemo(() => {
32-
const currentRouteMatches = router.matchRoutes(customActiveLocation() ?? activeLocation(), {
33-
_buildLocation: false,
34-
})
40+
const currentRouteMatches = router.matchRoutes(
41+
customActiveLocation() ?? activeLocation(),
42+
{
43+
_buildLocation: false,
44+
},
45+
)
3546

3647
return (
3748
from ??

0 commit comments

Comments
 (0)