@tanstack/react-router 1.81.6 → 1.81.9
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/matchContext.cjs +4 -0
- package/dist/cjs/matchContext.cjs.map +1 -1
- package/dist/cjs/matchContext.d.cts +1 -0
- package/dist/cjs/router.cjs +9 -6
- package/dist/cjs/router.cjs.map +1 -1
- package/dist/cjs/router.d.cts +3 -3
- package/dist/cjs/useMatch.cjs +3 -1
- package/dist/cjs/useMatch.cjs.map +1 -1
- package/dist/esm/matchContext.d.ts +1 -0
- package/dist/esm/matchContext.js +4 -0
- package/dist/esm/matchContext.js.map +1 -1
- package/dist/esm/router.d.ts +3 -3
- package/dist/esm/router.js +9 -6
- package/dist/esm/router.js.map +1 -1
- package/dist/esm/useMatch.js +4 -2
- package/dist/esm/useMatch.js.map +1 -1
- package/package.json +3 -3
- package/src/matchContext.tsx +5 -0
- package/src/router.ts +22 -12
- package/src/useMatch.tsx +4 -2
|
@@ -19,5 +19,9 @@ function _interopNamespaceDefault(e) {
|
|
|
19
19
|
}
|
|
20
20
|
const React__namespace = /* @__PURE__ */ _interopNamespaceDefault(React);
|
|
21
21
|
const matchContext = React__namespace.createContext(void 0);
|
|
22
|
+
const dummyMatchContext = React__namespace.createContext(
|
|
23
|
+
void 0
|
|
24
|
+
);
|
|
25
|
+
exports.dummyMatchContext = dummyMatchContext;
|
|
22
26
|
exports.matchContext = matchContext;
|
|
23
27
|
//# sourceMappingURL=matchContext.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"matchContext.cjs","sources":["../../src/matchContext.tsx"],"sourcesContent":["import * as React from 'react'\n\nexport const matchContext = React.createContext<string | undefined>(undefined)\n"],"names":["React"],"mappings":";;;;;;;;;;;;;;;;;;;;AAEa,MAAA,eAAeA,iBAAM,cAAkC,MAAS
|
|
1
|
+
{"version":3,"file":"matchContext.cjs","sources":["../../src/matchContext.tsx"],"sourcesContent":["import * as React from 'react'\n\nexport const matchContext = React.createContext<string | undefined>(undefined)\n\n// N.B. this only exists so we can conditionally call useContext on it when we are not interested in the nearest match\nexport const dummyMatchContext = React.createContext<string | undefined>(\n undefined,\n)\n"],"names":["React"],"mappings":";;;;;;;;;;;;;;;;;;;;AAEa,MAAA,eAAeA,iBAAM,cAAkC,MAAS;AAGtE,MAAM,oBAAoBA,iBAAM;AAAA,EACrC;AACF;;;"}
|
package/dist/cjs/router.cjs
CHANGED
|
@@ -1556,13 +1556,17 @@ class Router {
|
|
|
1556
1556
|
decodeCharMap: this.pathParamsDecodeCharMap
|
|
1557
1557
|
}) + loaderDepsHash;
|
|
1558
1558
|
const existingMatch = this.getMatch(matchId);
|
|
1559
|
-
const
|
|
1559
|
+
const previousMatch = this.state.matches.find(
|
|
1560
|
+
(d) => d.routeId === route.id
|
|
1561
|
+
);
|
|
1562
|
+
const cause = previousMatch ? "stay" : "enter";
|
|
1560
1563
|
let match;
|
|
1561
1564
|
if (existingMatch) {
|
|
1562
1565
|
match = {
|
|
1563
1566
|
...existingMatch,
|
|
1564
1567
|
cause,
|
|
1565
|
-
params: routeParams
|
|
1568
|
+
params: previousMatch ? utils.replaceEqualDeep(previousMatch.params, routeParams) : routeParams,
|
|
1569
|
+
search: previousMatch ? utils.replaceEqualDeep(previousMatch.search, preMatchSearch) : utils.replaceEqualDeep(existingMatch.search, preMatchSearch)
|
|
1566
1570
|
};
|
|
1567
1571
|
} else {
|
|
1568
1572
|
const status = route.options.loader || route.options.beforeLoad || route.lazyFn || routeNeedsPreload(route) ? "pending" : "success";
|
|
@@ -1570,10 +1574,10 @@ class Router {
|
|
|
1570
1574
|
id: matchId,
|
|
1571
1575
|
index,
|
|
1572
1576
|
routeId: route.id,
|
|
1573
|
-
params: routeParams,
|
|
1577
|
+
params: previousMatch ? utils.replaceEqualDeep(previousMatch.params, routeParams) : routeParams,
|
|
1574
1578
|
pathname: path.joinPaths([this.basepath, interpolatedPath]),
|
|
1575
1579
|
updatedAt: Date.now(),
|
|
1576
|
-
search:
|
|
1580
|
+
search: previousMatch ? utils.replaceEqualDeep(previousMatch.search, preMatchSearch) : preMatchSearch,
|
|
1577
1581
|
searchError: void 0,
|
|
1578
1582
|
status,
|
|
1579
1583
|
isFetching: false,
|
|
@@ -1585,7 +1589,7 @@ class Router {
|
|
|
1585
1589
|
abortController: new AbortController(),
|
|
1586
1590
|
fetchCount: 0,
|
|
1587
1591
|
cause,
|
|
1588
|
-
loaderDeps,
|
|
1592
|
+
loaderDeps: previousMatch ? utils.replaceEqualDeep(previousMatch.loaderDeps, loaderDeps) : loaderDeps,
|
|
1589
1593
|
invalid: false,
|
|
1590
1594
|
preload: false,
|
|
1591
1595
|
links: (_d = (_c = route.options).links) == null ? void 0 : _d.call(_c),
|
|
@@ -1609,7 +1613,6 @@ class Router {
|
|
|
1609
1613
|
if (!(opts == null ? void 0 : opts.preload)) {
|
|
1610
1614
|
match.globalNotFound = globalNotFoundRouteId === route.id;
|
|
1611
1615
|
}
|
|
1612
|
-
match.search = utils.replaceEqualDeep(match.search, preMatchSearch);
|
|
1613
1616
|
match.searchError = searchError;
|
|
1614
1617
|
const parentMatchId = parentMatch == null ? void 0 : parentMatch.id;
|
|
1615
1618
|
const parentContext = !parentMatchId ? this.options.context ?? {} : parentMatch.context ?? this.options.context ?? {};
|