Routing using useNavigate

This commit is contained in:
MuhammadKhalilzadeh committed 2024-06-07 13:20:07 +03:30
1 parent a6f4601da5
commit 551fa4de81
4 files changed
+19 -18

No files matched your search

@@ -1,5 +1,6 @@
import "./index.css";
import React, { useState } from "react";
import { useNavigate } from "react-router-dom";
/**
* Renders a menu button with an icon and title.
@@ -10,11 +11,13 @@ import React, { useState } from "react";
* @returns {React.ReactElement} The rendered menu button component.
*/
const DashboardMenuButton = (icon, title) => {
const DashboardMenuButton = (icon, title, to) => {
const [isActive, setIsActive] = useState(false);
const navigate = useNavigate();
const handleClick = () => {
setIsActive(!isActive);
navigate(to);
};
return (