Using <Navigate to={} /> with Layout routes?
I recently switched to file based routing and i'm having some issues using the
Navigate component with _layout routes
my tree looks like this (copied from gen, names changed)
To avoid raw strings, I've externalized my routes to a file like this:
But, if I try to Navigate to one of the routes I get this error:
Type "/_home/a" is not assignable to type
I know I could take A_PATH.replace(HOME_PATH, '') and it'd work, but it seems odd the router "can't figure this out". Am I missing something?2 Replies
typical-coralOP•2y ago
The reason
HOME_PATH was interpolated into A_PATH was because the router said it needed the fully qualified path when creating the route. (I wasn't allowed to say /a, it hd to be /_home/a when createFileRoute
Point is, I could absolutely rearrange this all to work, but is there some way to tell Navigate to go to a component that is part of a layout route without removing the layout routes?useful-bronze•2y ago
Navigating to
/_home/a wouldn't be possible since the /_home segment is a part of pathless/layout routes, so that doesn't get put into the URL.
It'd be /a instead of /_home/a.