@tanstack/react-router 0.0.1-beta.205 → 0.0.1-beta.206
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/build/cjs/RouterProvider.js +11 -9
- package/build/cjs/RouterProvider.js.map +1 -1
- package/build/esm/index.js +11 -9
- package/build/esm/index.js.map +1 -1
- package/build/stats-html.html +1 -1
- package/build/stats-react.json +165 -165
- package/build/umd/index.development.js +11 -9
- package/build/umd/index.development.js.map +1 -1
- package/build/umd/index.production.js +1 -1
- package/build/umd/index.production.js.map +1 -1
- package/package.json +2 -4
- package/src/RouterProvider.tsx +16 -10
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tanstack/react-router",
|
|
3
3
|
"author": "Tanner Linsley",
|
|
4
|
-
"version": "0.0.1-beta.
|
|
4
|
+
"version": "0.0.1-beta.206",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": "tanstack/router",
|
|
7
7
|
"homepage": "https://tanstack.com/router",
|
|
@@ -40,11 +40,9 @@
|
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
42
|
"@babel/runtime": "^7.16.7",
|
|
43
|
-
"@gisatcz/cross-package-react-context": "^0.2.0",
|
|
44
|
-
"@tanstack/react-router": "^0.0.1-beta.203",
|
|
45
43
|
"tiny-invariant": "^1.3.1",
|
|
46
44
|
"tiny-warning": "^1.0.3",
|
|
47
|
-
"@tanstack/history": "0.0.1-beta.
|
|
45
|
+
"@tanstack/history": "0.0.1-beta.206"
|
|
48
46
|
},
|
|
49
47
|
"scripts": {
|
|
50
48
|
"build": "rollup --config rollup.config.js"
|
package/src/RouterProvider.tsx
CHANGED
|
@@ -528,7 +528,7 @@ export function RouterProvider<
|
|
|
528
528
|
} = {},
|
|
529
529
|
matches?: AnyRouteMatch[],
|
|
530
530
|
): ParsedLocation => {
|
|
531
|
-
const from =
|
|
531
|
+
const from = latestLocationRef.current
|
|
532
532
|
const fromPathname = dest.from ?? from.pathname
|
|
533
533
|
|
|
534
534
|
let pathname = resolvePathWithBase(fromPathname, `${dest.to ?? ''}`)
|
|
@@ -697,7 +697,7 @@ export function RouterProvider<
|
|
|
697
697
|
async (next: ParsedLocation & CommitLocationOptions) => {
|
|
698
698
|
if (navigateTimeoutRef.current) clearTimeout(navigateTimeoutRef.current)
|
|
699
699
|
|
|
700
|
-
const isSameUrl =
|
|
700
|
+
const isSameUrl = latestLocationRef.current.href === next.href
|
|
701
701
|
|
|
702
702
|
// If the next urls are the same and we're not replacing,
|
|
703
703
|
// do nothing
|
|
@@ -741,7 +741,7 @@ export function RouterProvider<
|
|
|
741
741
|
)
|
|
742
742
|
|
|
743
743
|
const buildAndCommitLocation = useStableCallback(
|
|
744
|
-
|
|
744
|
+
({
|
|
745
745
|
replace,
|
|
746
746
|
resetScroll,
|
|
747
747
|
...rest
|
|
@@ -844,7 +844,7 @@ export function RouterProvider<
|
|
|
844
844
|
params: match.params,
|
|
845
845
|
preload: !!preload,
|
|
846
846
|
meta: parentMeta,
|
|
847
|
-
location: state.location,
|
|
847
|
+
location: state.location, // TODO: This might need to be latestLocationRef.current...?
|
|
848
848
|
})) ?? ({} as any)
|
|
849
849
|
|
|
850
850
|
const meta = {
|
|
@@ -1158,21 +1158,21 @@ export function RouterProvider<
|
|
|
1158
1158
|
const preloadDelay = userPreloadDelay ?? options.defaultPreloadDelay ?? 0
|
|
1159
1159
|
|
|
1160
1160
|
// Compare path/hash for matches
|
|
1161
|
-
const currentPathSplit =
|
|
1161
|
+
const currentPathSplit = latestLocationRef.current.pathname.split('/')
|
|
1162
1162
|
const nextPathSplit = next.pathname.split('/')
|
|
1163
1163
|
const pathIsFuzzyEqual = nextPathSplit.every(
|
|
1164
1164
|
(d, i) => d === currentPathSplit[i],
|
|
1165
1165
|
)
|
|
1166
1166
|
// Combine the matches based on user options
|
|
1167
1167
|
const pathTest = activeOptions?.exact
|
|
1168
|
-
?
|
|
1168
|
+
? latestLocationRef.current.pathname === next.pathname
|
|
1169
1169
|
: pathIsFuzzyEqual
|
|
1170
1170
|
const hashTest = activeOptions?.includeHash
|
|
1171
|
-
?
|
|
1171
|
+
? latestLocationRef.current.hash === next.hash
|
|
1172
1172
|
: true
|
|
1173
1173
|
const searchTest =
|
|
1174
1174
|
activeOptions?.includeSearch ?? true
|
|
1175
|
-
? partialDeepEqual(
|
|
1175
|
+
? partialDeepEqual(latestLocationRef.current.search, next.search)
|
|
1176
1176
|
: true
|
|
1177
1177
|
|
|
1178
1178
|
// The final "active" test
|
|
@@ -1252,12 +1252,16 @@ export function RouterProvider<
|
|
|
1252
1252
|
},
|
|
1253
1253
|
)
|
|
1254
1254
|
|
|
1255
|
+
const latestLocationRef = React.useRef(state.location)
|
|
1256
|
+
|
|
1255
1257
|
React.useLayoutEffect(() => {
|
|
1256
1258
|
const unsub = history.subscribe(() => {
|
|
1259
|
+
latestLocationRef.current = parseLocation(latestLocationRef.current)
|
|
1260
|
+
|
|
1257
1261
|
React.startTransition(() => {
|
|
1258
1262
|
setState((s) => ({
|
|
1259
1263
|
...s,
|
|
1260
|
-
location:
|
|
1264
|
+
location: latestLocationRef.current,
|
|
1261
1265
|
}))
|
|
1262
1266
|
})
|
|
1263
1267
|
})
|
|
@@ -1309,7 +1313,9 @@ export function RouterProvider<
|
|
|
1309
1313
|
return false
|
|
1310
1314
|
}
|
|
1311
1315
|
|
|
1312
|
-
const baseLocation = opts?.pending
|
|
1316
|
+
const baseLocation = opts?.pending
|
|
1317
|
+
? latestLocationRef.current
|
|
1318
|
+
: state.resolvedLocation
|
|
1313
1319
|
|
|
1314
1320
|
if (!baseLocation) {
|
|
1315
1321
|
return false
|