pstream is dead; long live pstream taciturnaxolotl.github.io/pstream-ng/
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge pull request #975 from qtchaos/fix/button-navigate

When navigating to own pages, use `useNavigate()`

authored by

William Oldham and committed by
GitHub
27aff999 bada1d12

+8 -2
+8 -2
src/components/buttons/Button.tsx
··· 1 1 import classNames from "classnames"; 2 2 import { ReactNode, useCallback } from "react"; 3 + import { useNavigate } from "react-router-dom"; 3 4 4 5 import { Icon, Icons } from "@/components/Icon"; 5 6 import { Spinner } from "@/components/layout/Spinner"; ··· 20 21 } 21 22 22 23 export function Button(props: Props) { 24 + const navigate = useNavigate(); 23 25 const { onClick, href, loading } = props; 24 26 const cb = useCallback( 25 27 ( ··· 31 33 if (loading) return; 32 34 if (href && !onClick) { 33 35 event.preventDefault(); 34 - window.open(href, "_blank", "noreferrer"); 36 + if (!href.includes("http")) { 37 + navigate(href); 38 + } else { 39 + window.open(href, "_blank", "noreferrer"); 40 + } 35 41 } else onClick?.(event); 36 42 }, 37 - [onClick, href, loading], 43 + [loading, href, onClick, navigate], 38 44 ); 39 45 40 46 let colorClasses = "bg-white hover:bg-gray-200 text-black";