1
0
Fork 0
mirror of https://github.com/sussy-code/smov.git synced 2024-12-20 14:37:43 +01:00

fix: use window.open instead of react-router on href within Button

This commit is contained in:
qtchaos 2024-02-26 16:56:46 +02:00
parent d1c58041c4
commit e8d8c16d41
No known key found for this signature in database
GPG key ID: 7DA98B2B9EF06A90

View file

@ -21,7 +21,6 @@ interface Props {
}
export function Button(props: Props) {
const navigate = useNavigate();
const { onClick, href, loading } = props;
const cb = useCallback(
(
@ -31,10 +30,12 @@ export function Button(props: Props) {
>,
) => {
if (loading) return;
if (href && !onClick) navigate(href);
else onClick?.(event);
if (href && !onClick) {
event.preventDefault();
window.open(href, "_blank", "noreferrer");
} else onClick?.(event);
},
[onClick, href, navigate, loading],
[onClick, href, loading],
);
let colorClasses = "bg-white hover:bg-gray-200 text-black";