@tanstack/router-core 1.163.2 → 1.163.3
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/router.cjs +17 -9
- package/dist/cjs/router.cjs.map +1 -1
- package/dist/esm/router.js +17 -9
- package/dist/esm/router.js.map +1 -1
- package/package.json +1 -1
- package/src/router.ts +26 -9
package/package.json
CHANGED
package/src/router.ts
CHANGED
|
@@ -2406,9 +2406,16 @@ export class RouterCore<
|
|
|
2406
2406
|
|
|
2407
2407
|
// Commit the pending matches. If a previous match was
|
|
2408
2408
|
// removed, place it in the cachedMatches
|
|
2409
|
+
//
|
|
2410
|
+
// exitingMatches uses match.id (routeId + params + loaderDeps) so
|
|
2411
|
+
// navigating /foo?page=1 → /foo?page=2 correctly caches the page=1 entry.
|
|
2409
2412
|
let exitingMatches: Array<AnyRouteMatch> = []
|
|
2410
|
-
|
|
2411
|
-
|
|
2413
|
+
|
|
2414
|
+
// Lifecycle-hook identity uses routeId only so that navigating between
|
|
2415
|
+
// different params/deps of the same route fires onStay (not onLeave+onEnter).
|
|
2416
|
+
let hookExitingMatches: Array<AnyRouteMatch> = []
|
|
2417
|
+
let hookEnteringMatches: Array<AnyRouteMatch> = []
|
|
2418
|
+
let hookStayingMatches: Array<AnyRouteMatch> = []
|
|
2412
2419
|
|
|
2413
2420
|
batch(() => {
|
|
2414
2421
|
this.__store.setState((s) => {
|
|
@@ -2418,12 +2425,22 @@ export class RouterCore<
|
|
|
2418
2425
|
exitingMatches = previousMatches.filter(
|
|
2419
2426
|
(match) => !newMatches.some((d) => d.id === match.id),
|
|
2420
2427
|
)
|
|
2421
|
-
|
|
2428
|
+
|
|
2429
|
+
// Lifecycle-hook identity: routeId only (route presence in tree)
|
|
2430
|
+
hookExitingMatches = previousMatches.filter(
|
|
2431
|
+
(match) =>
|
|
2432
|
+
!newMatches.some((d) => d.routeId === match.routeId),
|
|
2433
|
+
)
|
|
2434
|
+
hookEnteringMatches = newMatches.filter(
|
|
2422
2435
|
(match) =>
|
|
2423
|
-
!previousMatches.some(
|
|
2436
|
+
!previousMatches.some(
|
|
2437
|
+
(d) => d.routeId === match.routeId,
|
|
2438
|
+
),
|
|
2424
2439
|
)
|
|
2425
|
-
|
|
2426
|
-
previousMatches.some(
|
|
2440
|
+
hookStayingMatches = newMatches.filter((match) =>
|
|
2441
|
+
previousMatches.some(
|
|
2442
|
+
(d) => d.routeId === match.routeId,
|
|
2443
|
+
),
|
|
2427
2444
|
)
|
|
2428
2445
|
|
|
2429
2446
|
return {
|
|
@@ -2455,9 +2472,9 @@ export class RouterCore<
|
|
|
2455
2472
|
//
|
|
2456
2473
|
;(
|
|
2457
2474
|
[
|
|
2458
|
-
[
|
|
2459
|
-
[
|
|
2460
|
-
[
|
|
2475
|
+
[hookExitingMatches, 'onLeave'],
|
|
2476
|
+
[hookEnteringMatches, 'onEnter'],
|
|
2477
|
+
[hookStayingMatches, 'onStay'],
|
|
2461
2478
|
] as const
|
|
2462
2479
|
).forEach(([matches, hook]) => {
|
|
2463
2480
|
matches.forEach((match) => {
|