Allow RefObject<T> in reach__router innerRef. (#43534)

While https://reach.tech/router/api/Link describes innerRef as a func,
it is actually passed to React's HTMLAnchorElement's "ref" prop as such:

`<a ref={ref || innerRef} ...`

See: https://github.com/reach/router/blob/master/src/index.js#L392-L405

HTMLAnchorElement's "ref" is defined as Ref<HTMLAnchorElement>.
This commit is contained in:
Eyas
2020-04-01 09:45:29 -07:00
committed by GitHub
parent 17673008d4
commit cb3d627af8
2 changed files with 4 additions and 1 deletions
+1 -1
View File
@@ -59,7 +59,7 @@ export interface LinkProps<TState> extends AnchorProps {
getProps?: (props: LinkGetProps) => {};
state?: TState;
/** @deprecated If using React >= 16.4, use ref instead. */
innerRef?: React.RefCallback<HTMLAnchorElement>;
innerRef?: React.Ref<HTMLAnchorElement>;
}
export interface LinkGetProps {
@@ -59,3 +59,6 @@ const handleRef = (el: HTMLAnchorElement) => {
};
render(<Link innerRef={handleRef} to="./foo"></Link>, document.getElementById('app-root'));
const refObject: React.RefObject<HTMLAnchorElement> = { current: null };
render(<Link innerRef={refObject} to="./foo"></Link>, document.getElementById('app-root'));