1
0
mirror of https://github.com/SomboChea/ui synced 2026-01-20 18:15:51 +07:00

ActionBar Component - Replaced class by func. comp (#330)

This commit is contained in:
Priscila Oliveira
2019-12-03 09:44:44 +01:00
committed by GitHub
parent fcad6fa794
commit 742971db0d
11 changed files with 297 additions and 218 deletions

View File

@@ -7,20 +7,26 @@ interface Props extends Pick<TextProps, 'variant'> {
external?: boolean;
className?: string;
to: string;
children?: React.ReactNode;
}
type LinkRef = HTMLAnchorElement;
/* eslint-disable verdaccio/jsx-spread */
const Link: React.FC<Props> = ({ external, to, children, variant, className, ...props }) => {
const Link = React.forwardRef<LinkRef, Props>(function Link(
{ external, to, children, variant, className, ...props },
ref
) {
const LinkTextContent = <Text variant={variant}>{children}</Text>;
return external ? (
<a className={className} href={to} rel="noopener noreferrer" target="_blank" {...props}>
<a className={className} href={to} ref={ref} rel="noopener noreferrer" target="_blank" {...props}>
{LinkTextContent}
</a>
) : (
<RouterLink className={className} to={to} {...props}>
<RouterLink className={className} innerRef={ref} to={to} {...props}>
{LinkTextContent}
</RouterLink>
);
};
});
export default Link;