@tanstack/router-core 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.
- package/build/cjs/packages/router-core/src/router.js +15 -7
- package/build/cjs/packages/router-core/src/router.js.map +1 -1
- package/build/esm/index.js +15 -7
- package/build/esm/index.js.map +1 -1
- package/build/stats-html.html +1 -1
- package/build/stats-react.json +132 -132
- package/build/types/index.d.ts +0 -1
- package/build/umd/index.development.js +15 -7
- 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 +1 -1
- package/src/router.ts +14 -9
package/package.json
CHANGED
package/src/router.ts
CHANGED
|
@@ -172,7 +172,6 @@ export interface RouterState {
|
|
|
172
172
|
location: Location
|
|
173
173
|
matches: RouteMatch[]
|
|
174
174
|
lastUpdated: number
|
|
175
|
-
loaderData: unknown
|
|
176
175
|
currentAction?: ActionState
|
|
177
176
|
latestAction?: ActionState
|
|
178
177
|
actions: Record<string, Action>
|
|
@@ -366,7 +365,6 @@ export function createRouter<
|
|
|
366
365
|
matches: [],
|
|
367
366
|
actions: {},
|
|
368
367
|
loaders: {},
|
|
369
|
-
loaderData: {} as any,
|
|
370
368
|
lastUpdated: Date.now(),
|
|
371
369
|
isFetching: false,
|
|
372
370
|
isPreloading: false,
|
|
@@ -409,11 +407,12 @@ export function createRouter<
|
|
|
409
407
|
// to the current location. Otherwise, load the current location.
|
|
410
408
|
if (next.href !== router.location.href) {
|
|
411
409
|
router.__.commitLocation(next, true)
|
|
412
|
-
} else {
|
|
413
|
-
router.loadLocation()
|
|
414
410
|
}
|
|
415
411
|
|
|
416
|
-
|
|
412
|
+
router.loadLocation()
|
|
413
|
+
|
|
414
|
+
const unsub = router.history.listen((event) => {
|
|
415
|
+
console.log(event.location)
|
|
417
416
|
router.loadLocation(
|
|
418
417
|
router.__.parseLocation(event.location, router.location),
|
|
419
418
|
)
|
|
@@ -440,6 +439,15 @@ export function createRouter<
|
|
|
440
439
|
},
|
|
441
440
|
|
|
442
441
|
update: (opts) => {
|
|
442
|
+
const newHistory = opts?.history !== router.history
|
|
443
|
+
if (!router.location || newHistory) {
|
|
444
|
+
if (opts?.history) {
|
|
445
|
+
router.history = opts.history
|
|
446
|
+
}
|
|
447
|
+
router.location = router.__.parseLocation(router.history.location)
|
|
448
|
+
router.state.location = router.location
|
|
449
|
+
}
|
|
450
|
+
|
|
443
451
|
Object.assign(router.options, opts)
|
|
444
452
|
|
|
445
453
|
const { basepath, routeConfig } = router.options
|
|
@@ -487,7 +495,7 @@ export function createRouter<
|
|
|
487
495
|
router.cancelMatches()
|
|
488
496
|
|
|
489
497
|
// Match the routes
|
|
490
|
-
const matches = router.matchRoutes(location.pathname, {
|
|
498
|
+
const matches = router.matchRoutes(router.location.pathname, {
|
|
491
499
|
strictParseParams: true,
|
|
492
500
|
})
|
|
493
501
|
|
|
@@ -1211,9 +1219,6 @@ export function createRouter<
|
|
|
1211
1219
|
},
|
|
1212
1220
|
}
|
|
1213
1221
|
|
|
1214
|
-
router.location = router.__.parseLocation(history.location)
|
|
1215
|
-
router.state.location = router.location
|
|
1216
|
-
|
|
1217
1222
|
router.update(userOptions)
|
|
1218
1223
|
|
|
1219
1224
|
// Allow frameworks to hook into the router creation
|