import { Location } from 'history' ; import { useLocation } from 'react-router-dom' ; import { useRouter } from './use_router' ; export function useParams ( ... args ) { const router = useRouter ( ) ; const location = useLocation ( ) ; let optional = false ; const last = args [ args . length - 1 ] ; if ( typeof last === 'boolean' ) { optional = last ; args . pop ( ) ; } const paths = args as string [ ] ; const getParamsArgs = [ ... paths , location , optional ] as [ never , Location < any > , boolean ] ; return router . getParams ( ... getParamsArgs ) ; }