@tanstack/router-core 1.131.17 → 1.131.18

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tanstack/router-core",
3
- "version": "1.131.17",
3
+ "version": "1.131.18",
4
4
  "description": "Modern and scalable routing for React applications",
5
5
  "author": "Tanner Linsley",
6
6
  "license": "MIT",
package/src/router.ts CHANGED
@@ -2697,10 +2697,12 @@ export class RouterCore<
2697
2697
  this.getMatch(matchId),
2698
2698
  loaderData,
2699
2699
  )
2700
- innerLoadContext.updateMatch(matchId, (prev) => ({
2701
- ...prev,
2702
- loaderData,
2703
- }))
2700
+ if (loaderData !== undefined) {
2701
+ innerLoadContext.updateMatch(matchId, (prev) => ({
2702
+ ...prev,
2703
+ loaderData,
2704
+ }))
2705
+ }
2704
2706
  }
2705
2707
 
2706
2708
  // Lazy option can modify the route options,
@@ -2837,14 +2839,16 @@ export class RouterCore<
2837
2839
  )
2838
2840
  : shouldReloadOption
2839
2841
 
2840
- innerLoadContext.updateMatch(matchId, (prev) => {
2841
- prev._nonReactive.loaderPromise = createControlledPromise<void>()
2842
- return {
2842
+ const nextPreload =
2843
+ !!preload && !this.state.matches.some((d) => d.id === matchId)
2844
+ const match = this.getMatch(matchId)!
2845
+ match._nonReactive.loaderPromise = createControlledPromise<void>()
2846
+ if (nextPreload !== match.preload) {
2847
+ innerLoadContext.updateMatch(matchId, (prev) => ({
2843
2848
  ...prev,
2844
- preload:
2845
- !!preload && !this.state.matches.some((d) => d.id === matchId),
2846
- }
2847
- })
2849
+ preload: nextPreload,
2850
+ }))
2851
+ }
2848
2852
 
2849
2853
  // If the route is successful and still fresh, just resolve
2850
2854
  const { status, invalid } = this.getMatch(matchId)!
@@ -2886,23 +2890,24 @@ export class RouterCore<
2886
2890
  }
2887
2891
  }
2888
2892
  }
2893
+ const match = this.getMatch(matchId)!
2889
2894
  if (!loaderIsRunningAsync) {
2890
- const match = this.getMatch(matchId)!
2891
2895
  match._nonReactive.loaderPromise?.resolve()
2892
2896
  match._nonReactive.loadPromise?.resolve()
2893
2897
  }
2894
2898
 
2895
- innerLoadContext.updateMatch(matchId, (prev) => {
2896
- clearTimeout(prev._nonReactive.pendingTimeout)
2897
- prev._nonReactive.pendingTimeout = undefined
2898
- if (!loaderIsRunningAsync) prev._nonReactive.loaderPromise = undefined
2899
- prev._nonReactive.dehydrated = undefined
2900
- return {
2899
+ clearTimeout(match._nonReactive.pendingTimeout)
2900
+ match._nonReactive.pendingTimeout = undefined
2901
+ if (!loaderIsRunningAsync) match._nonReactive.loaderPromise = undefined
2902
+ match._nonReactive.dehydrated = undefined
2903
+ const nextIsFetching = loaderIsRunningAsync ? match.isFetching : false
2904
+ if (nextIsFetching !== match.isFetching || match.invalid !== false) {
2905
+ innerLoadContext.updateMatch(matchId, (prev) => ({
2901
2906
  ...prev,
2902
- isFetching: loaderIsRunningAsync ? prev.isFetching : false,
2907
+ isFetching: nextIsFetching,
2903
2908
  invalid: false,
2904
- }
2905
- })
2909
+ }))
2910
+ }
2906
2911
  return this.getMatch(matchId)!
2907
2912
  }
2908
2913