mirror of
https://github.com/filecoin-project/slate.git
synced 2024-11-26 04:19:49 +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 Logging from "~/common/logging";
|
||||
|
||||
export class Link extends React.Component {
|
||||
class LinkPrimitive extends React.Component {
|
||||
state = {
|
||||
href: this.props.href
|
||||
? this.props.href
|
||||
@ -63,6 +63,7 @@ export class Link extends React.Component {
|
||||
};
|
||||
|
||||
render() {
|
||||
const { style, innerRef, css, target, href, title, children, ...props } = this.props;
|
||||
return (
|
||||
<span onClick={this._handleClick}>
|
||||
<a
|
||||
@ -70,17 +71,20 @@ export class Link extends React.Component {
|
||||
textDecoration: "none",
|
||||
color: "inherit",
|
||||
cursor: "pointer",
|
||||
...this.props.style,
|
||||
...style,
|
||||
}}
|
||||
css={this.props.css}
|
||||
target={this.props.target}
|
||||
href={this.state.href}
|
||||
aria-label={this.props["aria-label"]}
|
||||
title={this.props.title}
|
||||
ref={innerRef}
|
||||
css={css}
|
||||
target={target}
|
||||
href={href}
|
||||
title={title}
|
||||
{...props}
|
||||
>
|
||||
{this.props.children}
|
||||
{children}
|
||||
</a>
|
||||
</span>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export const Link = React.forwardRef((props, ref) => <LinkPrimitive {...props} innerRef={ref} />);
|
||||
|
Loading…
Reference in New Issue
Block a user