Merge pull request #24523 from p-jackson/link-inner-ref

react-router-dom: Add `innerRef` prop to <Link> component
This commit is contained in:
Nathan Shively-Sanders
2018-03-26 09:53:54 -07:00
committed by GitHub
2 changed files with 9 additions and 1 deletions

View File

@@ -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> {}

View File

@@ -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} />;