UNPKG

@shopify/polaris

Version:

Shopify’s product component library

20 lines (19 loc) 890 B
import * as tslib_1 from "tslib"; import React from 'react'; import { unstyled } from '../shared'; import { useLink } from '../../utilities/link'; // This does have a display name, but the linting has a bug in it // https://github.com/yannickcr/eslint-plugin-react/issues/2324 // eslint-disable-next-line react/display-name export const UnstyledLink = React.memo( // eslint-disable-next-line react/display-name React.forwardRef(function UnstyledLink(props, _ref) { const LinkComponent = useLink(); 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}/>); }));