Skip to content

Commit

Permalink
feat: allow narrowing of matches by the context of the whole match
Browse files Browse the repository at this point in the history
  • Loading branch information
chorobin committed Jul 29, 2024
1 parent 6624dbd commit 9808538
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/react-router/src/Matches.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -254,10 +254,15 @@ export function MatchRoute<
return params ? props.children : null
}

export type MakeRouteMatches<
TRouteTree extends AnyRoute,
TRouteId extends RouteIds<TRouteTree>,
> = TRouteId extends any ? MakeRouteMatch<TRouteTree, TRouteId> : never

export function useMatches<
TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],
TRouteId extends RouteIds<TRouteTree> = ParseRoute<TRouteTree>['id'],
TRouteMatch = MakeRouteMatch<TRouteTree, TRouteId>,
TRouteMatch = MakeRouteMatches<TRouteTree, TRouteId>,
T = Array<TRouteMatch>,
>(opts?: { select?: (matches: Array<TRouteMatch>) => T }): T {
return useRouterState({
Expand Down

0 comments on commit 9808538

Please sign in to comment.