Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions contributors.yml
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,7 @@
- xavier-lc
- xcsnowcity
- xdaxer
- y-nk
- yionr
- yracnet
- ytori
Expand Down
8 changes: 4 additions & 4 deletions packages/react-router/lib/hooks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ import {
import type {
Blocker,
BlockerFunction,
RelativeRoutingType,
Router as DataRouter,
RevalidationState,
Navigation,
RelativeRoutingType,
RevalidationState,
} from "./router/router";
import { IDLE_BLOCKER } from "./router/router";
import type {
Expand Down Expand Up @@ -1394,12 +1394,12 @@ export function useRevalidator(): {
* @mode data
* @returns An array of {@link UIMatch | UI matches} for the current route hierarchy
*/
export function useMatches(): UIMatch[] {
export function useMatches<Data = unknown, Handle = unknown>(): UIMatch<Data, Handle>[] {
let { matches, loaderData } = useDataRouterState(
DataRouterStateHook.UseMatches,
);
return React.useMemo(
() => matches.map((m) => convertRouteMatchToUiMatch(m, loaderData)),
() => matches.map((m) => convertRouteMatchToUiMatch<Data, Handle>(m, loaderData)),
[matches, loaderData],
);
}
Expand Down
4 changes: 2 additions & 2 deletions packages/react-router/lib/router/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -942,10 +942,10 @@ export interface UIMatch<Data = unknown, Handle = unknown> {
handle: Handle;
}

export function convertRouteMatchToUiMatch(
export function convertRouteMatchToUiMatch<Data = unknown, Handle = unknown>(
match: AgnosticDataRouteMatch,
loaderData: RouteData,
): UIMatch {
): UIMatch<Data, Handle> {
let { route, pathname, params } = match;
return {
id: route.id,
Expand Down
Loading