@tanstack/router-core 0.0.1-beta.13 → 0.0.1-beta.14
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 -6
- package/build/cjs/packages/router-core/src/router.js.map +1 -1
- package/build/esm/index.js +15 -6
- package/build/esm/index.js.map +1 -1
- package/build/stats-html.html +1 -1
- package/build/stats-react.json +128 -128
- package/build/umd/index.development.js +15 -6
- 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 +24 -12
package/package.json
CHANGED
package/src/router.ts
CHANGED
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
History,
|
|
7
7
|
MemoryHistory,
|
|
8
8
|
} from 'history'
|
|
9
|
+
import React from 'react'
|
|
9
10
|
import invariant from 'tiny-invariant'
|
|
10
11
|
import { GetFrameworkGeneric } from './frameworks'
|
|
11
12
|
|
|
@@ -407,16 +408,25 @@ export function createRouter<
|
|
|
407
408
|
return router.routesById[id]
|
|
408
409
|
},
|
|
409
410
|
notify: (): void => {
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
isFetching
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
411
|
+
const isFetching =
|
|
412
|
+
router.state.status === 'loading' ||
|
|
413
|
+
router.state.matches.some((d) => d.isFetching)
|
|
414
|
+
|
|
415
|
+
const isPreloading = Object.values(router.matchCache).some(
|
|
416
|
+
(d) =>
|
|
417
|
+
d.match.isFetching &&
|
|
418
|
+
!router.state.matches.find((dd) => dd.matchId === d.match.matchId),
|
|
419
|
+
)
|
|
420
|
+
|
|
421
|
+
if (
|
|
422
|
+
router.state.isFetching !== isFetching ||
|
|
423
|
+
router.state.isPreloading !== isPreloading
|
|
424
|
+
) {
|
|
425
|
+
router.state = {
|
|
426
|
+
...router.state,
|
|
427
|
+
isFetching,
|
|
428
|
+
isPreloading,
|
|
429
|
+
}
|
|
420
430
|
}
|
|
421
431
|
|
|
422
432
|
cascadeLoaderData(router.state.matches)
|
|
@@ -454,7 +464,7 @@ export function createRouter<
|
|
|
454
464
|
Object.assign(match, dehydratedMatch)
|
|
455
465
|
})
|
|
456
466
|
|
|
457
|
-
|
|
467
|
+
matches.forEach((match) => match.__.validate())
|
|
458
468
|
|
|
459
469
|
router.state = {
|
|
460
470
|
...router.state,
|
|
@@ -476,7 +486,9 @@ export function createRouter<
|
|
|
476
486
|
router.__.commitLocation(next, true)
|
|
477
487
|
}
|
|
478
488
|
|
|
479
|
-
|
|
489
|
+
if (!router.state.matches.length) {
|
|
490
|
+
router.load()
|
|
491
|
+
}
|
|
480
492
|
|
|
481
493
|
const unsub = router.history.listen((event) => {
|
|
482
494
|
router.load(router.__.parseLocation(event.location, router.location))
|