TanStackT
TanStack7mo ago
3 replies
uncertain-scarlet

relative navigation with dynamic source route?

I have a utility that makes the concept of a "Search Route" which basically allows things like modals or other widgets to be tied to a search param.

I have this following function i use to either open or close the route. the goal is basically i want the router to preserve it's current page, but i just want to modify the search params:
    function go(k: string, v?: unknown) {
      void navigate({
        to: ".",
        search: (prev) => ({ ...prev, [k]: v }),
      });
    }


previously this worked really well, but i recently migrated to the newer devinxi version and now it consistently navigates to the homepage

after re-reading the docs, I guess this sort of makes sense- although it claims every navigation is relative, which I sort if interpreted as if the above should work, it also mentions that if no from attr is provided then it will navigate from the root route, so
.
will take me to
/


is there anyway to do what i'm trying to do above? the search params as is start yelling at me if i remove to , presumably because it can't ensure that k is a valid search key for any route
Was this page helpful?