how to best update path params?
hey all :blob_wave:
My use case is that I have a workspace switcher, and there are multiple pages where the user can be inside the dashboard. If they switch from one workspace to another, we would like to keep them in the same page rather than set them at the base of the dashboard. What is the best way with tanStack Router to achieve this?
4 Replies
xenial-black•3mo ago
needs more context. ideally a complete minimal reproducer based on one of the existing router examples on stackblitz
metropolitan-bronze•3mo ago
Create a hook that listens to route updates and store the information you need in localstorage. Then have a beforeLoad on the main pages of the workspace, that loads the data from localstorage and throws a redirect to the correct subpage
Note that this will not only properly when using Start, as the beforeLoad will not run on the client during first navigation. For this you would need to have a fallback that triggers in a useEffect after hydration
flat-fuchsiaOP•3mo ago
this is what I ended up so far it's working the only issue is as you can see it's not typesafe

xenial-black•3mo ago
if you provide a complete example and a detailed description of what you try to achieve , we can have another look