T
TanStack14mo ago
like-gold

Why might search be persisted through navigation?

I am wondering: why might search items be carried through an imperative call to navigate({ to: '/some-place' }) (from useNavigate())? I cannot for the life of me figure out why, since the default behavior seems to be to clear the search items when navigate() is called even without explicit search: {}. In my case, explicitly calling navigate({ to: '/some-place', search: {} }) does not work--the search string is carried through. I cannot unfortunately reproduce this in a sample project. I'm happy to provide my full project's code but it relies on a separate backend. I'm hopeful that someone who really understands the internals of this library might be able to help. Thank you!
6 Replies
absent-sapphire
absent-sapphire14mo ago
I cannot unfortunately reproduce this in a sample project.
that's odd are you passing search: true into navigate somewhere?
like-gold
like-goldOP14mo ago
Not to my knowledge.
absent-sapphire
absent-sapphire14mo ago
is the search param originating from router? or coming from somewhere else?
like-gold
like-goldOP14mo ago
The first route/page is navigated to by navigate({ to: '/first-page'}, search: { redirect: '/other', expired: true }) (the expired is unimportant here). Those are the search values that are carried over when I navigate off of that route/page.
absent-sapphire
absent-sapphire14mo ago
which router version are you using?
like-gold
like-goldOP14mo ago
^1.38.1 I'll update and see what happens Updating to the latest 1.46.8 seems to have solved the issue. I had searched the github issues and hadn't found anything relevant, so I assumed it was still present in the newer version. I have no idea what changed. Thank you for your time! ✅

Did you find this page helpful?