79172682

Date: 2024-11-09 11:56:41
Score: 0.5
Natty:
Report link

What you are doing seems a little bit convoluted, I have a few things to add.

const [isnavMenuClicked, setMobileViewNav] = useState(false);

Even tho react use state hook doesn’t require that the variable and setter names match, conventionally, it’s common to name them similarly tho ease the understanding process

const [isMobileMenuOpen, setIsMobileMenuOpen] = useState(false);

Then, if this function does not have any other logic in it you don't really need it:

function isMobileMenuClicked(value) {
    setMobileViewNav(value);
}

if you remove it then you could pass the state setter to the navbar directly

<Navbar isMobileMenuClicked={() => setMobileMenuOpen(prev => !prev)} isnavMenuClicked={isMobileMenuOpen} />

and then in the navbar

<button className='w-8 md:w-10 lg:hidden' onClick={isMobileMenuClicked}>

This should now toggle on each click

Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Starts with a question (0.5): What you are
  • Low reputation (1):
Posted by: Cristian-Alexandru SANDU