Files
gameyfin/frontend/util/routing.ts
T
2024-03-06 23:35:41 +01:00

16 lines
440 B
TypeScript

import { useMatches } from 'react-router-dom';
type RouteMetadata = {
[key: string]: any;
};
/**
* Returns the `handle` object containing the metadata for the current route,
* or undefined if the route does not have defined a handle.
*/
export function useRouteMetadata(): RouteMetadata | undefined {
const matches = useMatches();
const match = matches[matches.length - 1];
return match?.handle as RouteMetadata | undefined;
}