mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-05-12 19:59:02 +08:00
Add innerRef prop to <Link> component
An `innerRef` prop was added to <Link> in `react-router-dom@4.2` The node will be an anchor tag, which is why I made the callback accept an `HTMLAnchorElement` rather than an `HTMLElement`, however this isn't explicitly documented.
This commit is contained in:
2
types/react-router-dom/index.d.ts
vendored
2
types/react-router-dom/index.d.ts
vendored
@@ -2,6 +2,7 @@
|
||||
// Project: https://github.com/ReactTraining/react-router
|
||||
// Definitions by: Tanguy Krotoff <https://github.com/tkrotoff>
|
||||
// Huy Nguyen <https://github.com/huy-nguyen>
|
||||
// Philip Jackson <https://github.com/p-jackson>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.6
|
||||
|
||||
@@ -44,6 +45,7 @@ export class HashRouter extends React.Component<HashRouterProps, any> {}
|
||||
export interface LinkProps extends React.AnchorHTMLAttributes<HTMLAnchorElement> {
|
||||
to: H.LocationDescriptor;
|
||||
replace?: boolean;
|
||||
innerRef?: (node: HTMLAnchorElement | null) => void;
|
||||
}
|
||||
export class Link extends React.Component<LinkProps, any> {}
|
||||
|
||||
|
||||
@@ -2,7 +2,8 @@ import * as React from 'react';
|
||||
import {
|
||||
NavLink,
|
||||
NavLinkProps,
|
||||
match
|
||||
match,
|
||||
Link
|
||||
} from 'react-router-dom';
|
||||
import * as H from 'history';
|
||||
|
||||
@@ -19,3 +20,8 @@ export default function(props: Props) {
|
||||
<NavLink {...rest} isActive={isActive}/>
|
||||
);
|
||||
}
|
||||
|
||||
<Link to="/url" />;
|
||||
|
||||
const acceptRef = (node: HTMLAnchorElement | null) => {};
|
||||
<Link to="/url" replace={true} innerRef={acceptRef} />;
|
||||
|
||||
Reference in New Issue
Block a user