From 77effde4285b5196c191645d7e7297f650d622e6 Mon Sep 17 00:00:00 2001 From: fufu-girl-meow Date: Tue, 24 Jun 2025 00:53:53 +0700 Subject: [PATCH] handleClick for BlackButton --- src/pages/components/customButton.jsx | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/pages/components/customButton.jsx b/src/pages/components/customButton.jsx index f6e2d23..7943f5a 100644 --- a/src/pages/components/customButton.jsx +++ b/src/pages/components/customButton.jsx @@ -1,12 +1,21 @@ import '../../css/customButton.css' import { useNavigate } from 'react-router-dom'; -function BlackButton({ text , to="/"}) { +function BlackButton({ text , to="/", onClick }) { const navigate = useNavigate(); + const handleClick = (e) => { + if (onClick) { + onClick(e); + } + if (!e.defaultPrevented && to) { + navigate(to, { replace: true }); + } + }; + return( - + ) } - -export default BlackButton \ No newline at end of file + +export default BlackButton