import { last } from 'lodash' ; import { useMatchRoutes } from './use_match_routes' ; import { useRouter } from './use_router' ; export function useRoutePath ( ) { const lastRouteMatch = last ( useMatchRoutes ( ) ) ; const router = useRouter ( ) ; if ( ! lastRouteMatch ) { throw new Error ( 'No route was matched' ) ; } return router . getRoutePath ( lastRouteMatch . route ) ; }