import { useMemo } from 'react' ; import { useLocation } from 'react-router-dom' ; import { RouteMatch } from './types' ; import { useRouter } from './use_router' ; export function useMatchRoutes ( path ? ) { const router = useRouter ( ) ; const location = useLocation ( ) ; const routeMatches = useMemo ( ( ) => { return typeof path === 'undefined' ? router . matchRoutes ( location ) : router . matchRoutes ( path as never , location ) ; } , [ path , router , location ] ) ; return routeMatches ; }