@tanstack/react-router 1.35.0 → 1.35.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/link.cjs +1 -2
- package/dist/cjs/link.cjs.map +1 -1
- package/dist/cjs/router.cjs +14 -7
- package/dist/cjs/router.cjs.map +1 -1
- package/dist/cjs/useNavigate.cjs +2 -4
- package/dist/cjs/useNavigate.cjs.map +1 -1
- package/dist/esm/link.js +1 -2
- package/dist/esm/link.js.map +1 -1
- package/dist/esm/router.js +14 -7
- package/dist/esm/router.js.map +1 -1
- package/dist/esm/useNavigate.js +2 -4
- package/dist/esm/useNavigate.js.map +1 -1
- package/package.json +1 -1
- package/src/link.tsx +0 -1
- package/src/router.ts +17 -6
- package/src/useNavigate.tsx +0 -2
package/src/router.ts
CHANGED
|
@@ -1102,14 +1102,27 @@ export class Router<
|
|
|
1102
1102
|
): ParsedLocation => {
|
|
1103
1103
|
let fromPath = this.latestLocation.pathname
|
|
1104
1104
|
let fromSearch = dest.fromSearch || this.latestLocation.search
|
|
1105
|
+
const looseRoutesByPath = this.routesByPath as Record<string, AnyRoute>
|
|
1106
|
+
|
|
1107
|
+
const fromRoute =
|
|
1108
|
+
dest.from !== undefined
|
|
1109
|
+
? looseRoutesByPath[trimPathRight(dest.from)]
|
|
1110
|
+
: undefined
|
|
1105
1111
|
|
|
1106
1112
|
const fromMatches = this.matchRoutes(
|
|
1107
1113
|
this.latestLocation.pathname,
|
|
1108
1114
|
fromSearch,
|
|
1109
1115
|
)
|
|
1110
1116
|
|
|
1111
|
-
|
|
1112
|
-
|
|
1117
|
+
const fromMatch = fromMatches.find((d) => d.routeId === fromRoute?.id)
|
|
1118
|
+
|
|
1119
|
+
fromPath = fromMatch?.pathname || fromPath
|
|
1120
|
+
|
|
1121
|
+
invariant(
|
|
1122
|
+
dest.from == null || fromMatch != null,
|
|
1123
|
+
'Could not find match for from: ' + dest.from,
|
|
1124
|
+
)
|
|
1125
|
+
|
|
1113
1126
|
fromSearch = last(fromMatches)?.search || this.latestLocation.search
|
|
1114
1127
|
|
|
1115
1128
|
const stayingMatches = matches?.filter((d) =>
|
|
@@ -1773,8 +1786,7 @@ export class Router<
|
|
|
1773
1786
|
preload: !!preload,
|
|
1774
1787
|
context: parentContext,
|
|
1775
1788
|
location,
|
|
1776
|
-
navigate: (opts: any) =>
|
|
1777
|
-
this.navigate({ ...opts, from: match.pathname }),
|
|
1789
|
+
navigate: (opts: any) => this.navigate({ ...opts }),
|
|
1778
1790
|
buildLocation: this.buildLocation,
|
|
1779
1791
|
cause: preload ? 'preload' : match.cause,
|
|
1780
1792
|
})) ?? ({} as any)
|
|
@@ -1827,8 +1839,7 @@ export class Router<
|
|
|
1827
1839
|
abortController: match.abortController,
|
|
1828
1840
|
context: match.context,
|
|
1829
1841
|
location,
|
|
1830
|
-
navigate: (opts) =>
|
|
1831
|
-
this.navigate({ ...opts, from: match.pathname } as any),
|
|
1842
|
+
navigate: (opts) => this.navigate({ ...opts } as any),
|
|
1832
1843
|
cause: preload ? 'preload' : match.cause,
|
|
1833
1844
|
route,
|
|
1834
1845
|
}
|
package/src/useNavigate.tsx
CHANGED
|
@@ -29,7 +29,6 @@ export function useNavigate<
|
|
|
29
29
|
(options: NavigateOptions) => {
|
|
30
30
|
return router.navigate({
|
|
31
31
|
...options,
|
|
32
|
-
from: options.to ? router.state.resolvedLocation.pathname : undefined,
|
|
33
32
|
})
|
|
34
33
|
},
|
|
35
34
|
[router],
|
|
@@ -63,7 +62,6 @@ export function Navigate<
|
|
|
63
62
|
|
|
64
63
|
React.useEffect(() => {
|
|
65
64
|
navigate({
|
|
66
|
-
from: props.to ? match.pathname : undefined,
|
|
67
65
|
...props,
|
|
68
66
|
} as any)
|
|
69
67
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|