-
-
Notifications
You must be signed in to change notification settings - Fork 10.8k
Closed
Description
What is the new or updated feature that you are suggesting?
I am interested in having the possibility to declare the parameters used within useMatch such as useMatch(':domain/:id/:category') with a generic version of useMatch to supply something such as this:
type RouteProps = {
readonly domain: string;
readonly id: string;
readonly category: string;
};
const match = useMatch<RouteProps>(':domain/:id/:category');Why should this feature be included?
The feature helps to refactor usages in expressions such as active={match?.params.category === path} which are otherwised not strictly typed since params is of type Record<string, string> right now. Changing the name of a param in the path pattern is inherently unsafe, however when there is an explicit generic type parameter one might be forced to update the underlying type and automatically refactor all usages.
Metadata
Metadata
Assignees
Labels
No labels