diff --git a/types/reach__router/index.d.ts b/types/reach__router/index.d.ts index 8cb291a5e4..07cf7ec9e0 100644 --- a/types/reach__router/index.d.ts +++ b/types/reach__router/index.d.ts @@ -4,6 +4,7 @@ // A.Mokhtar , // Awwit // wroughtec +// O.Jackman // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.8 @@ -161,4 +162,4 @@ export function useNavigate(): NavigateFn; export function useParams(): any; -export function useMatch(pathname: string): null | { uri: string; path: string }; +export function useMatch(pathname: string): null | { uri: string; path: string, [param: string]: string }; diff --git a/types/reach__router/reach__router-tests.tsx b/types/reach__router/reach__router-tests.tsx index ac859d18f5..53889a8865 100644 --- a/types/reach__router/reach__router-tests.tsx +++ b/types/reach__router/reach__router-tests.tsx @@ -7,7 +7,8 @@ import { LocationProvider, RouteComponentProps, Router, - Redirect + Redirect, + useMatch } from '@reach/router'; interface DashParams { @@ -22,6 +23,13 @@ const Dash = (props: RouteComponentProps) => ( const NotFound = (props: RouteComponentProps) =>
Route not found
; +const UseMatchCheck = (props: RouteComponentProps) => { + const match = useMatch('/params/:one'); + return ( +
{match ? match.one : 'NO PATH PARAM' }
+ ); +}; + render( @@ -32,6 +40,7 @@ render( +