Merge branch 'next-console-errors' into 'next'

Next console errors

See merge request soapbox-pub/soapbox-fe!1135
This commit is contained in:
Justin 2022-03-23 17:57:54 +00:00
commit 6c1ed1b79c
4 changed files with 37 additions and 0 deletions

Binary file not shown.

View file

@ -0,0 +1,37 @@
import * as React from 'react';
import { useHistory } from 'react-router-dom';
interface IPermaLink extends Pick<React.HTMLAttributes<HTMLAnchorElement>, 'dangerouslySetInnerHTML'> {
className?: string,
href: string,
title?: string,
to: string,
}
const Permalink: React.FC<IPermaLink> = (props) => {
const history = useHistory();
const { className, href, title, to, children, ...filteredProps } = props;
const handleClick = (event: React.MouseEvent<HTMLAnchorElement>) => {
if (event.button === 0 && !(event.ctrlKey || event.metaKey)) {
event.preventDefault();
history.push(to);
}
};
return (
<a
target='_blank'
href={href}
onClick={handleClick}
title={title}
className={`permalink${className ? ' ' + className : ''}`}
{...filteredProps}
>
{children}
</a>
);
};
export default Permalink;