import { ArrowLeftIcon } from "@heroicons/react/24/outline"; import { memo, useCallback } from "react"; import { useNavigate, useNavigationType } from "react-router"; interface BackButtonProps { path?: string; } const BackButton = ({ path }: BackButtonProps) => { const navigate = useNavigate(); const navType = useNavigationType(); const handleBack = useCallback(() => { if (path) { navigate(path); } else if (navType === "POP") { navigate("/"); } else { navigate(-1); } }, [navType, navigate, path]); return ( ); }; export default memo(BackButton);