T
TanStack3mo ago
sunny-green

retainSearchParams

How does retainSearchParams actually work? When i have routes /tasks and /tasks/$taskId If i go from /tasks to /tasks/123 u want to retain search params, but it actually doesn't. how come?
4 Replies
sunny-green
sunny-greenOP3mo ago
For this to work do i really need to add search={(prev) => prev} to search Link?
other-emerald
other-emerald3mo ago
You could also just pass
true
true
to
retainSearchParams
retainSearchParams
to keep the search while navigating.
sunny-green
sunny-greenOP2mo ago
It doesnt keep the search params while navigating to child routes though. Should i use the LInk the Route exposes like <Route.Link> to make this work?
other-emerald
other-emerald2mo ago
Can you provide some code example?

Did you find this page helpful?