I am trying to create an admin panel and in which I have a sidebar menu. I have created a dropdown menu and it's working using the useState hook but not working as I wanted. What I wanted is when I click on Clients so if statement should only run for its children only not for all sibling children.
const [isActive, setIsActive] = useState(false);
const handleToggle = () => {
setIsActive(!isActive)
}
Below is the dropdown code.
<li>
<a className={`${isActive?'open-sibling':'hidden-sibling'} left-menu-list`} onClick={handleToggle}>
<i className="las la-user-alt mr-2"></i>
<span>Clients</span>
<i className="las la-angle-up ml-auto"></i>
</a>
<ul>
<Link href="/clients/list">
<li>
<a className="left-menu-list">
<i className="las la-users mr-2"></i> View All Clients
</a>
</li>
</Link>
</ul>
</li>
Please find the GIF of the output:-