Search params getting lost when navigating
I'm trying to figure out a weird issue where search params are not getting set correctly when navigating. I haven't been able to reproduce it in a standalone app, so I haven't created a router bug yet. I first saw this on version 1.0.7 and I also tried 1.15.2 but got the same behavior.
We have a shared component that contains a
Link component with search params that is used on different routes. On some of the source routes, the link correctly navigates to the destination route, but on one particular source route, the destination route gets the search params from the source route rather than the search params from the Link.
If I copy the URL from the link and paste it into a new tab, it correctly loads the search params, so I know that the search in the Link is correct.
I console logged search from useSearch and search from useRouterState in our root route, and I found that they are different. When navigating, useRouterState has the correct search for 2 renders, and then somehow reverts back to the incorrect search from the previous route. useSearch however, only shows the incorrect search, it never gets the correct one.
I've looked through our app for things that might modify search but haven't found anything suspicious. Anyone have any ideas what might be going on here?
It seems to be similar to https://github.com/TanStack/router/issues/850 but it's not as easy to reproduce.GitHub
useSearch bug: renders 'undefined' in between re-renders · Issue #8...
Describe the bug I see is useSearch() re-renders the component on change with the following new updated value undefined new updated value On a full refresh with query param this works as expected n...
0 Replies