@tanstack/react-router 1.45.4 → 1.45.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/src/router.ts CHANGED
@@ -1147,22 +1147,13 @@ export class Router<
1147
1147
  } = {},
1148
1148
  matches?: Array<MakeRouteMatch<TRouteTree>>,
1149
1149
  ): ParsedLocation => {
1150
- // if the router is loading the previous location is what
1151
- // we should use because the old matches are still around
1152
- // and the latest location has already been updated.
1153
- // If the router is not loading we should always use the
1154
- // latest location because resolvedLocation can lag behind
1155
- // and the new matches could already render
1156
- const currentLocation = this.state.isLoading
1157
- ? this.state.resolvedLocation
1158
- : this.latestLocation
1159
-
1160
- const location = dest._fromLocation ?? currentLocation
1161
-
1162
- let fromPath = location.pathname
1163
- let fromSearch = dest.fromSearch || location.search
1164
-
1165
- const fromMatches = this.matchRoutes(location.pathname, fromSearch)
1150
+ const fromMatches =
1151
+ dest._fromLocation != null
1152
+ ? this.matchRoutes(
1153
+ dest._fromLocation.pathname,
1154
+ dest.fromSearch || dest._fromLocation.search,
1155
+ )
1156
+ : this.state.matches
1166
1157
 
1167
1158
  const fromMatch =
1168
1159
  dest.from != null
@@ -1175,14 +1166,14 @@ export class Router<
1175
1166
  )
1176
1167
  : undefined
1177
1168
 
1178
- fromPath = fromMatch?.pathname || fromPath
1169
+ const fromPath = fromMatch?.pathname || this.latestLocation.pathname
1179
1170
 
1180
1171
  invariant(
1181
1172
  dest.from == null || fromMatch != null,
1182
1173
  'Could not find match for from: ' + dest.from,
1183
1174
  )
1184
1175
 
1185
- fromSearch = last(fromMatches)?.search || this.latestLocation.search
1176
+ const fromSearch = last(fromMatches)?.search || this.latestLocation.search
1186
1177
 
1187
1178
  const stayingMatches = matches?.filter((d) =>
1188
1179
  fromMatches.find((e) => e.routeId === d.routeId),