Skip to content

Get typesafe child routes list #2197

Answered by schiller-manuel
UltimateGG asked this question in Q&A
Discussion options

You must be logged in to vote

You could use something like this:

type Parent = '/page/subpage/'
type ParentRoute = RouteByPath<RegisteredRouter['routeTree'], Parent>
type ChildRoutes = ParentRoute['types']['children'][keyof ParentRoute['types']['children']]
type ChildPaths = ChildRoutes['path']

const changeSubPage = (subPage: ChildPaths) => {
      navigate({ to: `/page/subpage/${subPage}`});
}

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@UltimateGG
Comment options

Answer selected by UltimateGG
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants