mirror of
https://github.com/filecoin-project/slate.git
synced 2024-11-29 16:54:09 +03:00
feat(Link): forwardRef
This commit is contained in:
parent
0a3869bb7e
commit
66b377a509
@ -2,7 +2,7 @@ import * as React from "react";
|
|||||||
import * as Strings from "~/common/strings";
|
import * as Strings from "~/common/strings";
|
||||||
import * as Logging from "~/common/logging";
|
import * as Logging from "~/common/logging";
|
||||||
|
|
||||||
export class Link extends React.Component {
|
class LinkPrimitive extends React.Component {
|
||||||
state = {
|
state = {
|
||||||
href: this.props.href
|
href: this.props.href
|
||||||
? this.props.href
|
? this.props.href
|
||||||
@ -63,6 +63,7 @@ export class Link extends React.Component {
|
|||||||
};
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
const { style, innerRef, css, target, href, title, children, ...props } = this.props;
|
||||||
return (
|
return (
|
||||||
<span onClick={this._handleClick}>
|
<span onClick={this._handleClick}>
|
||||||
<a
|
<a
|
||||||
@ -70,17 +71,20 @@ export class Link extends React.Component {
|
|||||||
textDecoration: "none",
|
textDecoration: "none",
|
||||||
color: "inherit",
|
color: "inherit",
|
||||||
cursor: "pointer",
|
cursor: "pointer",
|
||||||
...this.props.style,
|
...style,
|
||||||
}}
|
}}
|
||||||
css={this.props.css}
|
ref={innerRef}
|
||||||
target={this.props.target}
|
css={css}
|
||||||
href={this.state.href}
|
target={target}
|
||||||
aria-label={this.props["aria-label"]}
|
href={href}
|
||||||
title={this.props.title}
|
title={title}
|
||||||
|
{...props}
|
||||||
>
|
>
|
||||||
{this.props.children}
|
{children}
|
||||||
</a>
|
</a>
|
||||||
</span>
|
</span>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const Link = React.forwardRef((props, ref) => <LinkPrimitive {...props} innerRef={ref} />);
|
||||||
|
Loading…
Reference in New Issue
Block a user