@hackplan/polaris
Version:
Shopify’s product component library
18 lines (17 loc) • 735 B
JavaScript
import * as tslib_1 from "tslib";
import React from 'react';
import { unstyled } from '../shared';
import { usePolaris } from '../../hooks';
export default React.memo(function UnstyledLink(props) {
const polaris = usePolaris();
if (polaris && polaris.link) {
const LinkComponent = polaris.link.getLinkComponent();
if (LinkComponent) {
return <LinkComponent {...unstyled.props} {...props}/>;
}
}
const { external, url } = props, rest = tslib_1.__rest(props, ["external", "url"]);
const target = external ? '_blank' : undefined;
const rel = external ? 'noopener noreferrer' : undefined;
return (<a target={target} {...rest} href={url} rel={rel} {...unstyled.props}/>);
});