mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-05-30 01:47:21 +08:00
Add test
This commit is contained in:
21
types/react-router-dom/react-router-dom-tests.tsx
Normal file
21
types/react-router-dom/react-router-dom-tests.tsx
Normal file
@@ -0,0 +1,21 @@
|
||||
import * as React from 'react';
|
||||
import {
|
||||
NavLink,
|
||||
NavLinkProps,
|
||||
match
|
||||
} from 'react-router-dom';
|
||||
import * as H from 'history';
|
||||
|
||||
const getIsActive = (extraProp: string) => (match: match<any>, location: H.Location) => !!extraProp;
|
||||
|
||||
interface Props extends NavLinkProps {
|
||||
extraProp: string;
|
||||
}
|
||||
|
||||
export default function(props: Props) {
|
||||
const {extraProp, ...rest} = props;
|
||||
const isActive = getIsActive(extraProp);
|
||||
return (
|
||||
<NavLink {...rest} isActive={isActive}/>
|
||||
);
|
||||
}
|
||||
@@ -13,6 +13,7 @@
|
||||
"noEmit": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts"
|
||||
"index.d.ts",
|
||||
"react-router-dom-tests.tsx"
|
||||
]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user