mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-04 14:57:10 +00:00
Merge pull request #28090 from zoompie/master
Added typings for react-router-hash-link
This commit is contained in:
+19
@@ -0,0 +1,19 @@
|
||||
// Type definitions for react-router-hash-link 1.2
|
||||
// Project: https://github.com/rafrex/react-router-hash-link (Does not have to be to GitHub, but prefer linking to a source code repository rather than to a project website.)
|
||||
// Definitions by: Sam Baeck <https://github.com/zoompie>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.8
|
||||
|
||||
import * as React from 'react';
|
||||
import { LinkProps, NavLinkProps } from 'react-router-dom';
|
||||
|
||||
export interface HashLinkProps extends LinkProps {
|
||||
smooth?: boolean;
|
||||
scroll?: (element: HTMLElement) => void;
|
||||
}
|
||||
|
||||
export class HashLink extends React.Component<HashLinkProps, any> {}
|
||||
|
||||
export interface NavHashLinkProps extends NavLinkProps, HashLinkProps {}
|
||||
|
||||
export class NavHashLink extends React.Component<NavHashLinkProps, any> {}
|
||||
@@ -0,0 +1,24 @@
|
||||
import * as H from 'history';
|
||||
import * as React from 'react';
|
||||
import { match } from 'react-router';
|
||||
import { HashLink, NavHashLink, NavHashLinkProps } from 'react-router-hash-link';
|
||||
|
||||
interface Props extends NavHashLinkProps {
|
||||
extraProp: string;
|
||||
}
|
||||
|
||||
const getIsActive = (extraProp: string) => (match: match<any>, location: H.Location) => !!extraProp;
|
||||
|
||||
export default function(props: Props) {
|
||||
const {extraProp, ...rest} = props;
|
||||
const isActive = getIsActive(extraProp);
|
||||
return (
|
||||
<NavHashLink {...rest} isActive={isActive} />
|
||||
);
|
||||
}
|
||||
|
||||
<HashLink to="url" />;
|
||||
|
||||
const acceptRef = (node: HTMLAnchorElement | null) => {
|
||||
};
|
||||
<HashLink to="/url" replace={true} innerRef={acceptRef} />;
|
||||
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"jsx": "react",
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"react-router-hash-link-tests.tsx"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user