From e8d8c16d418b64db466352be1cdf48a958b38f7b Mon Sep 17 00:00:00 2001 From: qtchaos <72168435+qtchaos@users.noreply.github.com> Date: Mon, 26 Feb 2024 16:56:46 +0200 Subject: [PATCH 1/2] fix: use window.open instead of react-router on href within Button --- src/components/buttons/Button.tsx | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/components/buttons/Button.tsx b/src/components/buttons/Button.tsx index 1c1a2b61..cee00528 100644 --- a/src/components/buttons/Button.tsx +++ b/src/components/buttons/Button.tsx @@ -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"; From 5321afe2cdbdf9dce643f3d64c23bb45e6162f6f Mon Sep 17 00:00:00 2001 From: qtchaos <72168435+qtchaos@users.noreply.github.com> Date: Mon, 26 Feb 2024 17:06:35 +0200 Subject: [PATCH 2/2] chore: remove useNavigate import --- src/components/buttons/Button.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/components/buttons/Button.tsx b/src/components/buttons/Button.tsx index cee00528..f5c81b8d 100644 --- a/src/components/buttons/Button.tsx +++ b/src/components/buttons/Button.tsx @@ -1,6 +1,5 @@ import classNames from "classnames"; import { ReactNode, useCallback } from "react"; -import { useNavigate } from "react-router-dom"; import { Icon, Icons } from "@/components/Icon"; import { Spinner } from "@/components/layout/Spinner";