UNPKG

ra-core

Version:

Core components of react-admin, a frontend Framework for building admin applications on top of REST services, using ES6, React

20 lines (18 loc) 501 B
import { useRouterProvider } from './RouterProviderContext'; /** * Hook to access URL parameters. * This is a router-agnostic wrapper that uses the configured router provider. * * @example * const params = useParams<{ id: string }>(); * console.log(params.id); */ export const useParams = < T extends Record<string, string | undefined> = Record< string, string | undefined >, >(): T => { const provider = useRouterProvider(); return provider.useParams<T>(); };