@tanstack/react-router 1.94.0 → 1.95.0
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/index.cjs +2 -0
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.cts +1 -0
- package/dist/cjs/router.cjs +8 -1
- package/dist/cjs/router.cjs.map +1 -1
- package/dist/cjs/useCanGoBack.cjs +8 -0
- package/dist/cjs/useCanGoBack.cjs.map +1 -0
- package/dist/cjs/useCanGoBack.d.cts +1 -0
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.js +2 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/router.js +8 -1
- package/dist/esm/router.js.map +1 -1
- package/dist/esm/useCanGoBack.d.ts +1 -0
- package/dist/esm/useCanGoBack.js +8 -0
- package/dist/esm/useCanGoBack.js.map +1 -0
- package/package.json +2 -2
- package/src/index.tsx +2 -0
- package/src/router.ts +8 -1
- package/src/useCanGoBack.ts +5 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function useCanGoBack(): boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useCanGoBack.js","sources":["../../src/useCanGoBack.ts"],"sourcesContent":["import { useRouterState } from './useRouterState'\n\nexport function useCanGoBack() {\n return useRouterState({ select: (s) => s.location.state.__TSR_index !== 0 })\n}\n"],"names":[],"mappings":";AAEO,SAAS,eAAe;AACtB,SAAA,eAAe,EAAE,QAAQ,CAAC,MAAM,EAAE,SAAS,MAAM,gBAAgB,GAAG;AAC7E;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tanstack/react-router",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.95.0",
|
|
4
4
|
"description": "Modern and scalable routing for React applications",
|
|
5
5
|
"author": "Tanner Linsley",
|
|
6
6
|
"license": "MIT",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"jsesc": "^3.0.2",
|
|
54
54
|
"tiny-invariant": "^1.3.3",
|
|
55
55
|
"tiny-warning": "^1.0.3",
|
|
56
|
-
"@tanstack/history": "1.
|
|
56
|
+
"@tanstack/history": "1.95.0"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
59
|
"@testing-library/jest-dom": "^6.6.3",
|
package/src/index.tsx
CHANGED
package/src/router.ts
CHANGED
|
@@ -1893,7 +1893,10 @@ export class Router<
|
|
|
1893
1893
|
...rest
|
|
1894
1894
|
}: BuildNextOptions & CommitLocationOptions = {}) => {
|
|
1895
1895
|
if (href) {
|
|
1896
|
-
const
|
|
1896
|
+
const currentIndex = this.history.location.state.__TSR_index
|
|
1897
|
+
const parsed = parseHref(href, {
|
|
1898
|
+
__TSR_index: replace ? currentIndex : currentIndex + 1,
|
|
1899
|
+
})
|
|
1897
1900
|
rest.to = parsed.pathname
|
|
1898
1901
|
rest.search = this.options.parseSearch(parsed.search)
|
|
1899
1902
|
// remove the leading `#` from the hash
|
|
@@ -2492,6 +2495,10 @@ export class Router<
|
|
|
2492
2495
|
|
|
2493
2496
|
if (prevLoaderPromise) {
|
|
2494
2497
|
await prevLoaderPromise
|
|
2498
|
+
const match = this.getMatch(matchId)!
|
|
2499
|
+
if (match.error) {
|
|
2500
|
+
handleRedirectAndNotFound(match, match.error)
|
|
2501
|
+
}
|
|
2495
2502
|
} else {
|
|
2496
2503
|
const parentMatchPromise = matchPromises[index - 1] as any
|
|
2497
2504
|
const route = this.looseRoutesById[routeId]!
|