@tanstack/react-router 0.0.1-beta.205 → 0.0.1-beta.206
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 +11 -9
- package/build/cjs/RouterProvider.js.map +1 -1
- package/build/esm/index.js +11 -9
- package/build/esm/index.js.map +1 -1
- package/build/stats-html.html +1 -1
- package/build/stats-react.json +165 -165
- package/build/umd/index.development.js +11 -9
- 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 -4
- package/src/RouterProvider.tsx +16 -10
|
@@ -1279,7 +1279,7 @@
|
|
|
1279
1279
|
});
|
|
1280
1280
|
const buildLocation = useStableCallback((opts = {}) => {
|
|
1281
1281
|
const build = (dest = {}, matches) => {
|
|
1282
|
-
const from =
|
|
1282
|
+
const from = latestLocationRef.current;
|
|
1283
1283
|
const fromPathname = dest.from ?? from.pathname;
|
|
1284
1284
|
let pathname = resolvePathWithBase(fromPathname, `${dest.to ?? ''}`);
|
|
1285
1285
|
const fromMatches = matchRoutes(fromPathname, from.search);
|
|
@@ -1372,7 +1372,7 @@
|
|
|
1372
1372
|
});
|
|
1373
1373
|
const commitLocation = useStableCallback(async next => {
|
|
1374
1374
|
if (navigateTimeoutRef.current) clearTimeout(navigateTimeoutRef.current);
|
|
1375
|
-
const isSameUrl =
|
|
1375
|
+
const isSameUrl = latestLocationRef.current.href === next.href;
|
|
1376
1376
|
|
|
1377
1377
|
// If the next urls are the same and we're not replacing,
|
|
1378
1378
|
// do nothing
|
|
@@ -1490,7 +1490,7 @@
|
|
|
1490
1490
|
params: match.params,
|
|
1491
1491
|
preload: !!preload,
|
|
1492
1492
|
meta: parentMeta,
|
|
1493
|
-
location: state.location
|
|
1493
|
+
location: state.location // TODO: This might need to be latestLocationRef.current...?
|
|
1494
1494
|
})) ?? {};
|
|
1495
1495
|
const meta = {
|
|
1496
1496
|
...parentMeta,
|
|
@@ -1743,13 +1743,13 @@
|
|
|
1743
1743
|
const preloadDelay = userPreloadDelay ?? options.defaultPreloadDelay ?? 0;
|
|
1744
1744
|
|
|
1745
1745
|
// Compare path/hash for matches
|
|
1746
|
-
const currentPathSplit =
|
|
1746
|
+
const currentPathSplit = latestLocationRef.current.pathname.split('/');
|
|
1747
1747
|
const nextPathSplit = next.pathname.split('/');
|
|
1748
1748
|
const pathIsFuzzyEqual = nextPathSplit.every((d, i) => d === currentPathSplit[i]);
|
|
1749
1749
|
// Combine the matches based on user options
|
|
1750
|
-
const pathTest = activeOptions?.exact ?
|
|
1751
|
-
const hashTest = activeOptions?.includeHash ?
|
|
1752
|
-
const searchTest = activeOptions?.includeSearch ?? true ? partialDeepEqual(
|
|
1750
|
+
const pathTest = activeOptions?.exact ? latestLocationRef.current.pathname === next.pathname : pathIsFuzzyEqual;
|
|
1751
|
+
const hashTest = activeOptions?.includeHash ? latestLocationRef.current.hash === next.hash : true;
|
|
1752
|
+
const searchTest = activeOptions?.includeSearch ?? true ? partialDeepEqual(latestLocationRef.current.search, next.search) : true;
|
|
1753
1753
|
|
|
1754
1754
|
// The final "active" test
|
|
1755
1755
|
const isActive = pathTest && hashTest && searchTest;
|
|
@@ -1817,12 +1817,14 @@
|
|
|
1817
1817
|
disabled
|
|
1818
1818
|
};
|
|
1819
1819
|
});
|
|
1820
|
+
const latestLocationRef = React__namespace.useRef(state.location);
|
|
1820
1821
|
React__namespace.useLayoutEffect(() => {
|
|
1821
1822
|
const unsub = history.subscribe(() => {
|
|
1823
|
+
latestLocationRef.current = parseLocation(latestLocationRef.current);
|
|
1822
1824
|
React__namespace.startTransition(() => {
|
|
1823
1825
|
setState(s => ({
|
|
1824
1826
|
...s,
|
|
1825
|
-
location:
|
|
1827
|
+
location: latestLocationRef.current
|
|
1826
1828
|
}));
|
|
1827
1829
|
});
|
|
1828
1830
|
});
|
|
@@ -1862,7 +1864,7 @@
|
|
|
1862
1864
|
if (opts?.pending && state.status !== 'pending') {
|
|
1863
1865
|
return false;
|
|
1864
1866
|
}
|
|
1865
|
-
const baseLocation = opts?.pending ?
|
|
1867
|
+
const baseLocation = opts?.pending ? latestLocationRef.current : state.resolvedLocation;
|
|
1866
1868
|
if (!baseLocation) {
|
|
1867
1869
|
return false;
|
|
1868
1870
|
}
|