@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.
@@ -1279,7 +1279,7 @@
1279
1279
  });
1280
1280
  const buildLocation = useStableCallback((opts = {}) => {
1281
1281
  const build = (dest = {}, matches) => {
1282
- const from = state.location;
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 = state.location.href === next.href;
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 = state.location.pathname.split('/');
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 ? state.location.pathname === next.pathname : pathIsFuzzyEqual;
1751
- const hashTest = activeOptions?.includeHash ? state.location.hash === next.hash : true;
1752
- const searchTest = activeOptions?.includeSearch ?? true ? partialDeepEqual(state.location.search, next.search) : true;
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: parseLocation(state.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 ? state.location : state.resolvedLocation;
1867
+ const baseLocation = opts?.pending ? latestLocationRef.current : state.resolvedLocation;
1866
1868
  if (!baseLocation) {
1867
1869
  return false;
1868
1870
  }