Since I am new to react i am trying to maintain state separately for each onclick
const openMenu = (id) => {
setNavbarOpen(!navbarOpen);
closeMenu();
};
const closeMenu = () => {
setMenuActive(false);
};
<navContainer isMenuActive={isMenuActive}>
<ul>
{navItems.map((navItem) => (
<NavItem
data={navItem}
key={navItem.id}
onClick={() => openMenu(navItem)}
/>
))}
</ul>
</navContainer>
I am planning to open the menu and close the menu while clicking on same tab. If first menu is open then first menu should close while clicking. If I click the second menu instead of closing the first menu the second menu should opened. Now if i click the second menu the first menu gets closed and the second menu is not opening.
Basically I would like to maintain the state separately for each menu. Is it possible or any other ideas?