After 30 seconds, hovering on link with search param sets the search param
Describe the bug
After loading a page, and waiting 30 seconds, hovering on a link with a search param will set the search param. Its not set in the url unless you click, but the Route.useSearch() variable is set.
Your Example Website or App
https://stackblitz.com/edit/tanstack-router-mob5mz?file=src%2Froutes%2Findex.tsx
Steps to Reproduce the Bug or Issue
- Go to stackblitz repro
- After page is loaded, wait 30 seconds.
- Hover "My link" with the mouse
- A text appears that renders from the search parameter caught from
Route.useSearch().
Hovering before 30 does not cause issues.
Expected behavior
The search param should not be set by hovering.
Screenshots or Videos
No response
Platform
- OS: Windows 11 Version 23H2 (Build 22631.3007)
- Browser: Edge
- Version: 121.0.2277.128
- Chromium version: 121.0.6167.184
Additional context
No response
The time is controlled by staleAge.
// Lower to 1 second
const router = createRouter({
routeTree,
defaultPreload: 'intent',
defaultPreloadStaleTime: 1_000,
});
As a work-around, setting shouldReload: false in the Route mitigates the issue.
export const Route = createFileRoute('/')({
component: Home,
validateSearch: (search: Record<string, unknown>): MyParams => {
return {
categoryIds: search.categoryIds as string[] | undefined,
};
},
shouldReload: false,
});
or setting the defaultPreload to false or undefined in the route setup.
// Set up a Router instance
const router = createRouter({
routeTree,
defaultPreload: false,
});
should be fixed, please open a new issue if this is still relevant
should be fixed, please open a new issue if this is still relevant
I'm curious to know which change you expected to fix this issue? 1.22.9 still has the issue, and 1.23.0 contains no relevant changes. I'll open a new issue tomorrow.
I am experiencing this right now with v1.15.19. Have a few things I need to address before i can upgrade to the latest, but the shouldReload: false workaround appears to be working for me. Thank you for mentioning it.