-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Closed
Copy link
Description
Which project does this relate to?
Router
Describe the bug
Double rendering occurs on browser forward/back navigation when using useParams
or useSearch
hooks. This issue persists even with memoization and affects both Route.useXXX
and raw useXXX
variants.
Your Example Website or App
https://stackblitz.com/edit/tanstack-router-ujjze6?file=src%2Froutes%2Findex.tsx
Steps to Reproduce the Bug or Issue
- Open the provided reproducer.
- Open the browser's developer tools console.
- Click on the "Search A" and "Search B" links. Observe that only one log entry is printed per navigation.
- Use the browser's forward and back buttons to navigate between pages a few times. Notice that two duplicate log entries are printed per navigation.
- Navigate to the About page and repeat steps 3-4 to observe the same behavior with params instead of search.
Expected behavior
Components should render only once when navigating using browser forward/back buttons, consistent with the behavior observed when clicking links for navigation.
Screenshots or Videos
No response
Platform
N/A
Additional context
- Components do not double render if neither
useParams
noruseSearch
hooks are used. - The issue only occurs when using browser forward/back navigation, not when clicking links.
validateSearch
,search
middlewares,loaderDeps
, andloader
do not seem to affect the issue.- Preload settings also do not seem to affect the issue.
- Similar issue: Double Renders On Navigate #1825
matthiasschwarz, filipszu, futurliberta and jthomaschewski
Metadata
Metadata
Assignees
Labels
No labels