@tanstack/react-router 0.0.1-beta.257 → 0.0.1-beta.259
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 +7 -0
- package/build/cjs/RouterProvider.js.map +1 -1
- package/build/cjs/redirects.js +3 -0
- package/build/cjs/redirects.js.map +1 -1
- package/build/esm/index.js +10 -0
- package/build/esm/index.js.map +1 -1
- package/build/stats-html.html +1 -1
- package/build/stats-react.json +355 -355
- package/build/types/redirects.d.ts +4 -3
- package/build/umd/index.development.js +10 -0
- 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 -2
- package/src/RouterProvider.tsx +13 -0
- package/src/redirects.ts +11 -3
|
@@ -3,8 +3,9 @@ import { AnyRoute } from './route';
|
|
|
3
3
|
import { RoutePaths } from './routeInfo';
|
|
4
4
|
import { RegisteredRouter } from './router';
|
|
5
5
|
export type AnyRedirect = Redirect<any, any, any>;
|
|
6
|
-
export type Redirect<TRouteTree extends AnyRoute = RegisteredRouter['routeTree'], TFrom extends RoutePaths<TRouteTree> = '/', TTo extends string = '', TMaskFrom extends RoutePaths<TRouteTree> = TFrom, TMaskTo extends string = ''> =
|
|
6
|
+
export type Redirect<TRouteTree extends AnyRoute = RegisteredRouter['routeTree'], TFrom extends RoutePaths<TRouteTree> = '/', TTo extends string = '', TMaskFrom extends RoutePaths<TRouteTree> = TFrom, TMaskTo extends string = ''> = {
|
|
7
7
|
code?: number;
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
throw?: any;
|
|
9
|
+
} & NavigateOptions<TRouteTree, TFrom, TTo, TMaskFrom, TMaskTo>;
|
|
10
|
+
export declare function redirect<TRouteTree extends AnyRoute = RegisteredRouter['routeTree'], TFrom extends RoutePaths<TRouteTree> = '/', TTo extends string = '', TMaskFrom extends RoutePaths<TRouteTree> = TFrom, TMaskTo extends string = ''>(opts: Redirect<TRouteTree, TFrom, TTo, TMaskFrom, TMaskTo>): Redirect<TRouteTree, TFrom, TTo, TMaskFrom, TMaskTo>;
|
|
10
11
|
export declare function isRedirect(obj: any): obj is AnyRedirect;
|
|
@@ -1515,6 +1515,13 @@
|
|
|
1515
1515
|
toLocation: routerState.location,
|
|
1516
1516
|
pathChanged: routerState.location.href !== routerState.resolvedLocation?.href
|
|
1517
1517
|
});
|
|
1518
|
+
if (routerState.location.hash !== routerState.resolvedLocation?.hash && document.querySelector) {
|
|
1519
|
+
console.log('hello', routerState.location.hash);
|
|
1520
|
+
const el = document.getElementById(routerState.location.hash);
|
|
1521
|
+
if (el) {
|
|
1522
|
+
el.scrollIntoView();
|
|
1523
|
+
}
|
|
1524
|
+
}
|
|
1518
1525
|
router.pendingMatches = [];
|
|
1519
1526
|
router.__store.setState(s => ({
|
|
1520
1527
|
...s,
|
|
@@ -1797,6 +1804,9 @@
|
|
|
1797
1804
|
|
|
1798
1805
|
function redirect(opts) {
|
|
1799
1806
|
opts.isRedirect = true;
|
|
1807
|
+
if (opts.throw) {
|
|
1808
|
+
throw opts;
|
|
1809
|
+
}
|
|
1800
1810
|
return opts;
|
|
1801
1811
|
}
|
|
1802
1812
|
function isRedirect(obj) {
|