@tanstack/react-router 0.0.1-beta.4 → 0.0.1-beta.5

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.
@@ -1739,7 +1739,6 @@ function createRouter(userOptions) {
1739
1739
  matches: [],
1740
1740
  actions: {},
1741
1741
  loaders: {},
1742
- loaderData: {},
1743
1742
  lastUpdated: Date.now(),
1744
1743
  isFetching: false,
1745
1744
  isPreloading: false
@@ -1773,11 +1772,11 @@ function createRouter(userOptions) {
1773
1772
 
1774
1773
  if (next.href !== router.location.href) {
1775
1774
  router.__.commitLocation(next, true);
1776
- } else {
1777
- router.loadLocation();
1778
1775
  }
1779
1776
 
1780
- const unsub = history.listen(event => {
1777
+ router.loadLocation();
1778
+ const unsub = router.history.listen(event => {
1779
+ console.log(event.location);
1781
1780
  router.loadLocation(router.__.parseLocation(event.location, router.location));
1782
1781
  }); // addEventListener does not exist in React Native, but window does
1783
1782
  // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
@@ -1799,6 +1798,17 @@ function createRouter(userOptions) {
1799
1798
  router.loadLocation();
1800
1799
  },
1801
1800
  update: opts => {
1801
+ const newHistory = (opts == null ? void 0 : opts.history) !== router.history;
1802
+
1803
+ if (!router.location || newHistory) {
1804
+ if (opts != null && opts.history) {
1805
+ router.history = opts.history;
1806
+ }
1807
+
1808
+ router.location = router.__.parseLocation(router.history.location);
1809
+ router.state.location = router.location;
1810
+ }
1811
+
1802
1812
  Object.assign(router.options, opts);
1803
1813
  const {
1804
1814
  basepath,
@@ -1847,7 +1857,7 @@ function createRouter(userOptions) {
1847
1857
 
1848
1858
  router.cancelMatches(); // Match the routes
1849
1859
 
1850
- const matches = router.matchRoutes(location.pathname, {
1860
+ const matches = router.matchRoutes(router.location.pathname, {
1851
1861
  strictParseParams: true
1852
1862
  });
1853
1863
  router.state = _extends({}, router.state, {
@@ -2449,8 +2459,6 @@ function createRouter(userOptions) {
2449
2459
  }
2450
2460
  }
2451
2461
  };
2452
- router.location = router.__.parseLocation(history.location);
2453
- router.state.location = router.location;
2454
2462
  router.update(userOptions); // Allow frameworks to hook into the router creation
2455
2463
 
2456
2464
  router.options.createRouter == null ? void 0 : router.options.createRouter(router);