T
TanStack2y ago
metropolitan-bronze

Is there a way to get Route.fullPath using createLazyFileRoute?

Im migrating to the new version, in the old version I just imported Route into my lazy loaded component. but now, I have a route in the route.tsx and a lazyroute in my route.lazy.tsx, do I need to import the route from the route.tsx to get fullPath (as a different name, as there is already a Route variable for the lazyfileroute in route.lazy.tsx)
2 Replies
other-emerald
other-emerald2y ago
Assuming this is for the page, you could use the useRouterState hook on the page.
const location = useRouterState({ select: (s) => s.location })
// ^ - this will have the full href, pathname, and whatnot
// just console log it and you'll see everything you'd have access to
const location = useRouterState({ select: (s) => s.location })
// ^ - this will have the full href, pathname, and whatnot
// just console log it and you'll see everything you'd have access to
metropolitan-bronze
metropolitan-bronzeOP2y ago
sounds good, thanks! hm, The issue with it is that it gives me the state of the current location of the URL while i need to location of the specific route <Link to={location.pathname + '/$postId'} now when I go to another route, it keeps adding postId's instead of just having the Posts/postid rn I do an import lik ethis
import { Route as NotLazyRoute } from "./route";
import { Route as NotLazyRoute } from "./route";
then I use NotLazyRoute.fullPath

Did you find this page helpful?