Skip to content

Commit eeeaeda

Browse files
committed
fix(react-router): fix logic to conditionally set pendingMatches based on browser location changes
Signed-off-by: leesb971204 <leesb971204@gmail.com>
1 parent 7fc6d11 commit eeeaeda

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

packages/react-router/src/router.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1959,8 +1959,11 @@ export class Router<
19591959
try {
19601960
const next = this.latestLocation
19611961
const prevLocation = this.state.resolvedLocation
1962+
const actualBrowserLocation = this.state.location
19621963
const hrefChanged = prevLocation.href !== next.href
19631964
const pathChanged = prevLocation.pathname !== next.pathname
1965+
const browserLocationChanged =
1966+
actualBrowserLocation.href !== next.href
19641967

19651968
// Cancel any pending matches
19661969
this.cancelMatches()
@@ -2047,9 +2050,10 @@ export class Router<
20472050
isLoading: false,
20482051
loadedAt: Date.now(),
20492052
matches: newMatches,
2050-
pendingMatches: hasPendingFetches
2051-
? s.pendingMatches
2052-
: undefined,
2053+
pendingMatches:
2054+
hasPendingFetches && browserLocationChanged
2055+
? s.pendingMatches
2056+
: undefined,
20532057
cachedMatches: [
20542058
...s.cachedMatches,
20552059
...exitingMatches.filter((d) => d.status !== 'error'),

0 commit comments

Comments
 (0)