mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-08-12 13:00:19 +00:00
Fix @reach/router .useMatch types. Path params are added to the return object. (#43248)
This commit is contained in:
Vendored
+2
-1
@@ -4,6 +4,7 @@
|
||||
// A.Mokhtar <https://github.com/xMokAx>,
|
||||
// Awwit <https://github.com/awwit>
|
||||
// wroughtec <https://github.com/wroughtec>
|
||||
// O.Jackman <https://github.com/chilledoj>
|
||||
// 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 };
|
||||
|
||||
@@ -7,7 +7,8 @@ import {
|
||||
LocationProvider,
|
||||
RouteComponentProps,
|
||||
Router,
|
||||
Redirect
|
||||
Redirect,
|
||||
useMatch
|
||||
} from '@reach/router';
|
||||
|
||||
interface DashParams {
|
||||
@@ -22,6 +23,13 @@ const Dash = (props: RouteComponentProps<DashParams>) => (
|
||||
|
||||
const NotFound = (props: RouteComponentProps) => <div>Route not found</div>;
|
||||
|
||||
const UseMatchCheck = (props: RouteComponentProps) => {
|
||||
const match = useMatch('/params/:one');
|
||||
return (
|
||||
<div>{match ? match.one : 'NO PATH PARAM' }</div>
|
||||
);
|
||||
};
|
||||
|
||||
render(
|
||||
<Router className="my-class">
|
||||
<Router component="div">
|
||||
@@ -32,6 +40,7 @@ render(
|
||||
</Router>
|
||||
<Home path="/" />
|
||||
<Dash path="/default/:id" />
|
||||
<UseMatchCheck path="/params/*" />
|
||||
<NotFound default />
|
||||
|
||||
<Link to="/somepath" rel="noopener noreferrer" target="_blank" />
|
||||
|
||||
Reference in New Issue
Block a user