@tanstack/react-router 1.52.3 → 1.52.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/dist/cjs/router.cjs +12 -7
- package/dist/cjs/router.cjs.map +1 -1
- package/dist/esm/router.js +12 -7
- package/dist/esm/router.js.map +1 -1
- package/package.json +1 -1
- package/src/router.ts +27 -20
package/package.json
CHANGED
package/src/router.ts
CHANGED
|
@@ -1643,11 +1643,6 @@ export class Router<
|
|
|
1643
1643
|
load = async (): Promise<void> => {
|
|
1644
1644
|
this.latestLocation = this.parseLocation(this.latestLocation)
|
|
1645
1645
|
|
|
1646
|
-
this.__store.setState((s) => ({
|
|
1647
|
-
...s,
|
|
1648
|
-
loadedAt: Date.now(),
|
|
1649
|
-
}))
|
|
1650
|
-
|
|
1651
1646
|
let redirect: ResolvedRedirect | undefined
|
|
1652
1647
|
let notFound: NotFoundError | undefined
|
|
1653
1648
|
|
|
@@ -1738,6 +1733,7 @@ export class Router<
|
|
|
1738
1733
|
return {
|
|
1739
1734
|
...s,
|
|
1740
1735
|
isLoading: false,
|
|
1736
|
+
loadedAt: Date.now(),
|
|
1741
1737
|
matches: newMatches,
|
|
1742
1738
|
pendingMatches: undefined,
|
|
1743
1739
|
cachedMatches: [
|
|
@@ -1975,12 +1971,38 @@ export class Router<
|
|
|
1975
1971
|
const existingMatch = this.getMatch(matchId)!
|
|
1976
1972
|
const parentMatchId = matches[index - 1]?.id
|
|
1977
1973
|
|
|
1974
|
+
const route = this.looseRoutesById[routeId]!
|
|
1975
|
+
|
|
1976
|
+
const pendingMs =
|
|
1977
|
+
route.options.pendingMs ?? this.options.defaultPendingMs
|
|
1978
|
+
|
|
1979
|
+
const shouldPending = !!(
|
|
1980
|
+
onReady &&
|
|
1981
|
+
!this.isServer &&
|
|
1982
|
+
!preload &&
|
|
1983
|
+
(route.options.loader || route.options.beforeLoad) &&
|
|
1984
|
+
typeof pendingMs === 'number' &&
|
|
1985
|
+
pendingMs !== Infinity &&
|
|
1986
|
+
(route.options.pendingComponent ??
|
|
1987
|
+
this.options.defaultPendingComponent)
|
|
1988
|
+
)
|
|
1989
|
+
|
|
1978
1990
|
if (
|
|
1979
1991
|
// If we are in the middle of a load, either of these will be present
|
|
1980
1992
|
// (not to be confused with `loadPromise`, which is always defined)
|
|
1981
1993
|
existingMatch.beforeLoadPromise ||
|
|
1982
1994
|
existingMatch.loaderPromise
|
|
1983
1995
|
) {
|
|
1996
|
+
if (shouldPending) {
|
|
1997
|
+
setTimeout(() => {
|
|
1998
|
+
try {
|
|
1999
|
+
// Update the match and prematurely resolve the loadMatches promise so that
|
|
2000
|
+
// the pending component can start rendering
|
|
2001
|
+
triggerOnReady()
|
|
2002
|
+
} catch {}
|
|
2003
|
+
}, pendingMs)
|
|
2004
|
+
}
|
|
2005
|
+
|
|
1984
2006
|
// Wait for the beforeLoad to resolve before we continue
|
|
1985
2007
|
await existingMatch.beforeLoadPromise
|
|
1986
2008
|
} else {
|
|
@@ -1994,23 +2016,8 @@ export class Router<
|
|
|
1994
2016
|
beforeLoadPromise: createControlledPromise<void>(),
|
|
1995
2017
|
}))
|
|
1996
2018
|
|
|
1997
|
-
const route = this.looseRoutesById[routeId]!
|
|
1998
2019
|
const abortController = new AbortController()
|
|
1999
2020
|
|
|
2000
|
-
const pendingMs =
|
|
2001
|
-
route.options.pendingMs ?? this.options.defaultPendingMs
|
|
2002
|
-
|
|
2003
|
-
const shouldPending = !!(
|
|
2004
|
-
onReady &&
|
|
2005
|
-
!this.isServer &&
|
|
2006
|
-
!preload &&
|
|
2007
|
-
(route.options.loader || route.options.beforeLoad) &&
|
|
2008
|
-
typeof pendingMs === 'number' &&
|
|
2009
|
-
pendingMs !== Infinity &&
|
|
2010
|
-
(route.options.pendingComponent ??
|
|
2011
|
-
this.options.defaultPendingComponent)
|
|
2012
|
-
)
|
|
2013
|
-
|
|
2014
2021
|
let pendingTimeout: ReturnType<typeof setTimeout>
|
|
2015
2022
|
|
|
2016
2023
|
if (shouldPending) {
|