T
TanStack2y ago
sensitive-blue

Infer routes type to a custom component

I'm making a custom component that have a Link inside, I would like to pass the to route via props to the component, is there a type to get all the available routes in the same way the to prop of the Link does?
<Link to="/settings">Back</Link>
<Link to="/settings">Back</Link>
2 Replies
fascinating-indigo
fascinating-indigo2y ago
You can spread LinkProps into your component’s props and get it from there ✨
sensitive-blue
sensitive-blueOP2y ago
I tried doing this:
LinkProps & {
onClick?: () => void;
}
LinkProps & {
onClick?: () => void;
}
but the to type is any for some reason nevermind it's working thanks!

Did you find this page helpful?