Merge pull request #34464 from eps1lon/fix/react-router-dom/ref-objects

[react-router-dom] Allow ref objects in Link.innerRef
This commit is contained in:
Benjamin Lichtman
2019-04-11 16:58:45 -07:00
committed by GitHub
2 changed files with 6 additions and 3 deletions

View File

@@ -4,6 +4,7 @@
// Huy Nguyen <https://github.com/huy-nguyen>
// Philip Jackson <https://github.com/p-jackson>
// John Reilly <https://github.com/johnnyreilly>
// Sebastian Silbermann <https://github.com/eps1lon>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.8
@@ -47,7 +48,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;
innerRef?: React.Ref<HTMLAnchorElement>;
}
export class Link extends React.Component<LinkProps, any> {}

View File

@@ -39,5 +39,7 @@ const Component: React.SFC<OtherProps> = props => {
<Link to="/url" />;
const acceptRef = (node: HTMLAnchorElement | null) => {};
<Link to="/url" replace={true} innerRef={acceptRef} />;
const refCallback: React.Ref<HTMLAnchorElement> = node => {};
<Link to="/url" replace={true} innerRef={refCallback} />;
const ref = React.createRef<HTMLAnchorElement>();
<Link to="/url" replace={true} innerRef={ref} />;