@tanstack/react-router 1.34.3 → 1.34.5
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/RouterProvider.cjs.map +1 -1
- package/dist/cjs/RouterProvider.d.cts +3 -1
- package/dist/cjs/Transitioner.cjs +1 -0
- package/dist/cjs/Transitioner.cjs.map +1 -1
- package/dist/cjs/router.cjs +16 -8
- package/dist/cjs/router.cjs.map +1 -1
- package/dist/cjs/router.d.cts +6 -0
- package/dist/esm/RouterProvider.d.ts +3 -1
- package/dist/esm/RouterProvider.js.map +1 -1
- package/dist/esm/Transitioner.js +1 -0
- package/dist/esm/Transitioner.js.map +1 -1
- package/dist/esm/router.d.ts +6 -0
- package/dist/esm/router.js +16 -8
- package/dist/esm/router.js.map +1 -1
- package/package.json +1 -1
- package/src/RouterProvider.tsx +3 -1
- package/src/Transitioner.tsx +1 -6
- package/src/router.ts +24 -10
package/src/router.ts
CHANGED
|
@@ -7,7 +7,6 @@ import { defaultParseSearch, defaultStringifySearch } from './searchParams'
|
|
|
7
7
|
import {
|
|
8
8
|
createControlledPromise,
|
|
9
9
|
deepEqual,
|
|
10
|
-
escapeJSON,
|
|
11
10
|
functionalUpdate,
|
|
12
11
|
last,
|
|
13
12
|
pick,
|
|
@@ -421,6 +420,12 @@ export const componentTypes = [
|
|
|
421
420
|
] as const
|
|
422
421
|
|
|
423
422
|
export type RouterEvents = {
|
|
423
|
+
onBeforeNavigate: {
|
|
424
|
+
type: 'onBeforeNavigate'
|
|
425
|
+
fromLocation: ParsedLocation
|
|
426
|
+
toLocation: ParsedLocation
|
|
427
|
+
pathChanged: boolean
|
|
428
|
+
}
|
|
424
429
|
onBeforeLoad: {
|
|
425
430
|
type: 'onBeforeLoad'
|
|
426
431
|
fromLocation: ParsedLocation
|
|
@@ -1374,7 +1379,7 @@ export class Router<
|
|
|
1374
1379
|
})
|
|
1375
1380
|
}
|
|
1376
1381
|
|
|
1377
|
-
navigate: NavigateFn = ({ from, to, ...rest }) => {
|
|
1382
|
+
navigate: NavigateFn = ({ from, to, __isRedirect, ...rest }) => {
|
|
1378
1383
|
// If this link simply reloads the current route,
|
|
1379
1384
|
// make sure it has a new key so it will trigger a data refresh
|
|
1380
1385
|
|
|
@@ -1423,13 +1428,6 @@ export class Router<
|
|
|
1423
1428
|
// Cancel any pending matches
|
|
1424
1429
|
this.cancelMatches()
|
|
1425
1430
|
|
|
1426
|
-
this.emit({
|
|
1427
|
-
type: 'onBeforeLoad',
|
|
1428
|
-
fromLocation: prevLocation,
|
|
1429
|
-
toLocation: next,
|
|
1430
|
-
pathChanged: pathDidChange,
|
|
1431
|
-
})
|
|
1432
|
-
|
|
1433
1431
|
let pendingMatches!: Array<AnyRouteMatch>
|
|
1434
1432
|
|
|
1435
1433
|
this.__store.batch(() => {
|
|
@@ -1454,6 +1452,22 @@ export class Router<
|
|
|
1454
1452
|
}))
|
|
1455
1453
|
})
|
|
1456
1454
|
|
|
1455
|
+
if (!this.state.redirect) {
|
|
1456
|
+
this.emit({
|
|
1457
|
+
type: 'onBeforeNavigate',
|
|
1458
|
+
fromLocation: prevLocation,
|
|
1459
|
+
toLocation: next,
|
|
1460
|
+
pathChanged: pathDidChange,
|
|
1461
|
+
})
|
|
1462
|
+
}
|
|
1463
|
+
|
|
1464
|
+
this.emit({
|
|
1465
|
+
type: 'onBeforeLoad',
|
|
1466
|
+
fromLocation: prevLocation,
|
|
1467
|
+
toLocation: next,
|
|
1468
|
+
pathChanged: pathDidChange,
|
|
1469
|
+
})
|
|
1470
|
+
|
|
1457
1471
|
await this.loadMatches({
|
|
1458
1472
|
matches: pendingMatches,
|
|
1459
1473
|
location: next,
|
|
@@ -1516,7 +1530,7 @@ export class Router<
|
|
|
1516
1530
|
if (isResolvedRedirect(err)) {
|
|
1517
1531
|
redirect = err
|
|
1518
1532
|
if (!this.isServer) {
|
|
1519
|
-
this.navigate({ ...err, replace: true })
|
|
1533
|
+
this.navigate({ ...err, replace: true, __isRedirect: true })
|
|
1520
1534
|
this.load()
|
|
1521
1535
|
}
|
|
1522
1536
|
} else if (isNotFound(err)) {
|