diff options
Diffstat (limited to 'examples/with-create-react-app/packages/ui/src/Link.tsx')
| -rw-r--r-- | examples/with-create-react-app/packages/ui/src/Link.tsx | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/examples/with-create-react-app/packages/ui/src/Link.tsx b/examples/with-create-react-app/packages/ui/src/Link.tsx new file mode 100644 index 0000000..416bac8 --- /dev/null +++ b/examples/with-create-react-app/packages/ui/src/Link.tsx @@ -0,0 +1,20 @@ +import * as React from "react"; + +interface LinkProps extends React.AnchorHTMLAttributes<HTMLAnchorElement> { + children: React.ReactNode; + href: string; +} + +export const Link = (props: LinkProps) => { + const { children, href, ...rest } = props; + + if (rest.target === "_blank") { + rest.rel = "noopener noreferrer"; + } + + return ( + <a href={href} {...rest}> + {children} + </a> + ); +}; |
